@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 1.3 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../assert/is-array.js";import e from"./../assert/is-typed-array-like.js";import t from"./../assert/is-integer.js";import n from"./../array/buffer.js";import a from"./../math/base/special/ceil2.js";function o(r,e){var t;for(t=e.length-1;t>=0;t--)r.unshift(e[t]);return r}function f(r,e){var t,n,a;for(t=r.length,n=e.length,a=t-1;a>=0;a--)r[a+n]=r[a];for(a=0;a<n;a++)r[a]=e[a];return r.length=t+n,r}var i=n,s=a;function u(r,e){var t,n,a,o,f,u,l,h;if(o=r.length,n=(u=e.length)*r.BYTES_PER_ELEMENT,(a=r.byteOffset)<n)for(t=o*r.BYTES_PER_ELEMENT,a=(f=new i(s(t+n+a+1))).byteLength-t-n,l=new r.constructor(f,a,o+u),h=0;h<o;h++)l[h+u]=r[h];else a-=n,l=new r.constructor(r.buffer,a,o+u);for(h=0;h<u;h++)l[h]=e[h];return l}var l=r,h=e,g=t,m=o,y=f,c=u;function p(r){var e,t;for(e=new Array(arguments.length-1),t=0;t<arguments.length-1;t++)e[t]=arguments[t+1];if(l(r))return m(r,e);if(h(r))return c(r,e);if(null!==r&&"object"==typeof r&&"number"==typeof r.length&&g(r.length)&&r.length>=0)return y(r,e);throw new TypeError("invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `"+r+"`.")}var E=p;export default E;
//# sourceMappingURL=unshift.js.map