-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
19 lines (19 loc) · 7.86 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"use strict";var o=function(e,i){return function(){return i||e((i={exports:{}}).exports,i),i.exports}};var p=o(function(Ve,y){"use strict";var Y=require("@stdlib/assert-is-integer").isPrimitive,B=require("@stdlib/ndarray-base-ind"),X=require("@stdlib/ndarray-base-ctor"),G=require("@stdlib/string-format"),w=X.prototype.iget;function H(e){if(this._ndims>0){if(!Y(e))throw new TypeError(G("invalid argument. Index must be an integer. Value: `%s`.",e));return e=B(e,this._length-1,this._mode),w.call(this,e)}return w.call(this)}y.exports=H});var _=o(function(xe,E){"use strict";var J=require("@stdlib/assert-is-integer").isPrimitive,K=require("@stdlib/ndarray-base-ind"),Q=require("@stdlib/ndarray-base-ctor"),U=require("@stdlib/string-format"),q=Q.prototype.iset;function W(e,i){if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(this._ndims>0){if(!J(e))throw new TypeError(U("invalid argument. Index must be an integer. Value: `%s`.",e));e=K(e,this._length-1,this._mode),q.call(this,e,i)}else q.call(this,e);return this}E.exports=W});var O=o(function(Ne,T){"use strict";var Z=require("@stdlib/assert-is-integer").isPrimitive,$=require("@stdlib/ndarray-base-ind"),I=require("@stdlib/string-format");function ee(){var e,i,t,r;if(arguments.length!==this._ndims)throw new RangeError(I("invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.",this._ndims,arguments.length));for(e=this._offset,t=this._submode.length,r=0;r<arguments.length;r++){if(!Z(arguments[r]))throw new TypeError(I("invalid argument. Indices must be integer valued. Argument: `%u`. Value: `%s`.",r,arguments[r]));i=$(arguments[r],this._shape[r]-1,this._submode[r%t]),e+=this._strides[r]*i}return this._accessors?this._buffer.get(e):this._buffer[e]}T.exports=ee});var N=o(function(Re,x){"use strict";var re=require("@stdlib/assert-is-integer").isPrimitive,ie=require("@stdlib/ndarray-base-ind"),V=require("@stdlib/string-format");function te(){var e,i,t,r;if(this._flags.READONLY)throw new Error("invalid invocation. Cannot write to a read-only array.");if(arguments.length!==this._ndims+1)throw new RangeError(V("invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.",this._ndims,arguments.length));for(e=this._offset,t=this._submode.length,r=0;r<arguments.length-1;r++){if(!re(arguments[r]))throw new TypeError(V("invalid argument. Indices must be integer valued. Argument: `%i`. Value: `%s`.",r,arguments[r]));i=ie(arguments[r],this._shape[r]-1,this._submode[r%t]),e+=this._strides[r]*i}return this._accessors?this._buffer.set(arguments[r],e):this._buffer[e]=arguments[r],this}x.exports=te});var A=o(function(Ae,R){"use strict";function ne(e,i){var t,r;for(t=[],r=0;r<i;r++)t.push(e[r]);return t}R.exports=ne});var F=o(function(De,j){"use strict";var ae=require("@stdlib/assert-is-plain-object"),v=require("@stdlib/assert-has-own-property"),se=require("@stdlib/assert-is-array-like-object"),D=require("@stdlib/ndarray-base-assert-is-index-mode"),ue=require("@stdlib/assert-is-boolean").isPrimitive,g=require("@stdlib/string-format");function oe(e,i){var t;if(!ae(i))return new TypeError(g("invalid argument. Options argument must be an object. Value: `%s`.",i));if(v(i,"mode")&&(e.mode=i.mode,!D(e.mode)))return new TypeError(g("invalid option. `%s` option must be a recognized mode. Option: `%s`.","mode",e.mode));if(v(i,"submode")){if(e.submode=i.submode,!se(e.submode))return new TypeError(g("invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.","submode",e.submode));if(e.submode.length===0)return new TypeError(g("invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.","submode",e.submode.join(",")));for(t=0;t<e.submode.length;t++)if(!D(e.submode[t]))return new TypeError(g("invalid option. Each submode must be a recognized mode. Option: `%s`.",e.submode[t]));e.submode=e.submode.slice()}return v(i,"readonly")&&(e.readonly=i.readonly,!ue(e.readonly))?new TypeError(g("invalid option. `%s` option must be a boolean. Option: `%s`.","readonly",e.readonly)):null}j.exports=oe});var C=o(function(je,S){"use strict";var l=require("@stdlib/utils-define-nonenumerable-read-only-property"),P=require("@stdlib/assert-is-collection"),me=require("@stdlib/assert-is-nonnegative-integer-array").primitives,ge=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,de=require("@stdlib/assert-is-integer-array").primitives,k=require("@stdlib/assert-is-function"),le=require("@stdlib/ndarray-base-assert-is-order"),he=require("@stdlib/ndarray-base-assert-is-data-type"),ve=require("@stdlib/ndarray-base-assert-is-buffer-length-compatible"),fe=require("@stdlib/ndarray-base-numel"),z=require("@stdlib/ndarray-base-ctor"),ce=require("@stdlib/ndarray-defaults"),be=require("@stdlib/utils-inherit"),n=require("@stdlib/string-format"),we=p(),ye=_(),pe=O(),qe=N(),L=A(),Ee=F(),M=32767,_e=ce.get("index_mode"),Ie=!1;function a(e,i,t,r,m,d,f){var s,u,h,c,b;if(!(this instanceof a))return arguments.length<7?new a(e,i,t,r,m,d):new a(e,i,t,r,m,d,f);if(!he(e))throw new TypeError(n("invalid argument. First argument must be a supported ndarray data type. Value: `%s`.",e));if(P(i)){if(i.get&&i.set&&(!k(i.get)||!k(i.set)))throw new TypeError(n("invalid argument. Second argument `get` and `set` properties must be functions. Value: `%s`.",i))}else throw new TypeError(n("invalid argument. Second argument must be an array-like object, typed-array-like, or a Buffer. Value: `%s`.",i));if(!me(t)&&(!P(t)||t.length>0))throw new TypeError(n("invalid argument. Third argument must be an array-like object containing nonnegative integers. Value: `%s`.",t));if(s=t.length,s>M)throw new RangeError(n("invalid argument. Number of dimensions must not exceed %u due to stack limits. Value: `%u`.",M,s));if(!de(r))throw new TypeError(n("invalid argument. Fourth argument must be an array-like object containing integers. Value: `%s`.",r));if(s>0){if(r.length!==s)throw new RangeError(n("invalid argument. Fourth argument length must match the number of dimensions. Expected number of dimensions: `%u`. Strides length: `%u`.",s,r.length))}else{if(r.length!==1)throw new RangeError("invalid argument. Fourth argument length must be equal to 1 when creating a zero-dimensional ndarray.");if(r[0]!==0)throw new RangeError(n("invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.",r[0]))}if(!ge(m))throw new TypeError(n("invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.",m));if(!le(d))throw new TypeError(n("invalid argument. Sixth argument must be a supported order. Value: `%s`.",d));if(s>0&&!ve(i.length,t,r,m)&&fe(t)>0)throw new Error("invalid arguments. Input buffer is incompatible with the specified meta data. Ensure that the offset is valid with regard to the strides array and that the buffer has enough elements to satisfy the desired array shape.");if(u={},u.mode=_e,u.readonly=Ie,arguments.length>6&&(h=Ee(u,f),h))throw h;return this._mode=u.mode,u.submode===void 0&&(u.submode=[this._mode]),this._submode=u.submode,c=L(t,s),b=L(r,s||1),z.call(this,e,i,c,b,m,d),this._flags.READONLY=u.readonly,this}be(a,z);l(a,"name","ndarray");l(a.prototype,"get",pe);l(a.prototype,"iget",we);l(a.prototype,"set",qe);l(a.prototype,"iset",ye);S.exports=a});var Te=C();module.exports=Te;
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//# sourceMappingURL=index.js.map