Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ndarray

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndarray - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

92

ndarray.js

@@ -30,15 +30,13 @@ "use strict"

};\
ZeroArray.prototype.size=0;\
ZeroArray.prototype.order=[];\
ZeroArray.prototype.get=function() {\
var proto=ZeroArray.prototype;\
proto.size=0;\
proto.order=[];\
proto.get=proto.set=function() {\
return Number.NaN\
};\
ZeroArray.prototype.set=function(v) {\
return Number.NaN\
};\
ZeroArray.prototype.lo=\
ZeroArray.prototype.hi=\
ZeroArray.prototype.transpose=\
ZeroArray.prototype.step=\
ZeroArray.prototype.pick=function() {\
proto.lo=\
proto.hi=\
proto.transpose=\
proto.step=\
proto.pick=function() {\
return new ZeroArray(this.data,this.shape,this.stride,this.offset)\

@@ -66,8 +64,9 @@ }"

//Create constructor
code.push(["function ", className, "(a,b,c,d){"].join(""))
code.push("this.data=a")
code.push("this.shape=b")
code.push("this.stride=c")
code.push("this.offset=d")
code.push("}")
code.push([
"function ", className, "(a,b,c,d){\
this.data=a;\
this.shape=b;\
this.stride=c;\
this.offset=d;\
}"].join(""))

@@ -81,8 +80,7 @@ //Create prototype

//view.size:
code.push(["Object.defineProperty(proto,'size',{get:function ",className,"_size(){var s=this.shape"].join(""))
code.push("return " + indices.map(function(i) {
return ["s[",i,"]"].join("")
}).join("*"))
code.push("}})")
code.push(["Object.defineProperty(proto,'size',{get:function ",className,"_size(){\
var s=this.shape;\
return ", indices.map(function(i) { return ["s[",i,"]"].join("") }).join("*"),
"}})"].join(""))
//view.order:

@@ -96,3 +94,3 @@ if(dimension === 1) {

if(dimension === 2) {
code.push("return (this.stride[0]>this.stride[1])?[1,0]:[0,1]")
code.push("return (this.stride[0]>this.stride[1])?[1,0]:[0,1]}})")
} else if(dimension === 3) {

@@ -115,14 +113,13 @@ code.push(

return [0,2,1];\
}")
}}})")
}
code.push("}")
} else {
code.push("ORDER")
code.push("ORDER})")
}
code.push("})")
}
//view.set(i0, ..., v):
code.push(["proto.set=function ",className,"_set(", args.join(","), ",v){"].join(""))
code.push("var a=this.stride")
code.push([
"proto.set=function ",className,"_set(", args.join(","), ",v){\
var a=this.stride"].join(""))
if(useGetters) {

@@ -135,4 +132,4 @@ code.push(["return this.data.set(", index_str, ",v)}"].join(""))

//view.get(i0, ...):
code.push(["proto.get=function ",className,"_get(", args.join(","), "){"].join(""))
code.push("var a=this.stride")
code.push(["proto.get=function ",className,"_get(", args.join(","), "){\
var a=this.stride"].join(""))
if(useGetters) {

@@ -155,7 +152,7 @@ code.push(["return this.data.get(", index_str, ")}"].join(""))

for(var i=0; i<dimension; ++i) {
code.push(["if(typeof i", i, "==='number'){"].join(""))
code.push(["d=i",i,"|0"].join(""))
code.push(["b+=c[",i,"]*d"].join(""))
code.push(["a[",i,"]-=d"].join(""))
code.push("}")
code.push([
"if(typeof i", i, "==='number'){\
d=i",i,"|0;\
b+=c[",i,"]*d;\
a[",i,"]-=d}"].join(""))
}

@@ -167,12 +164,13 @@ code.push(["return new ", className, "(this.data,a,c,b)}"].join(""))

for(var i=0; i<dimension; ++i) {
code.push("if(typeof i"+i+"==='number'){")
code.push("d=i"+i+"|0")
code.push("if(d<0){")
code.push("c+=b["+i+"]*(a["+i+"]-1)")
code.push("a["+i+"]=ceil(-a["+i+"]/d)")
code.push("}else{")
code.push("a["+i+"]=ceil(a["+i+"]/d)")
code.push("}")
code.push("b["+i+"]*=d")
code.push("}")
code.push([
"if(typeof i",i,"==='number'){\
d=i",i,"|0;\
if(d<0){\
c+=b[",i,"]*(a[",i,"]-1);\
a[",i,"]=ceil(-a[",i,"]/d)\
}else{\
a[",i,"]=ceil(a[",i,"]/d)\
}\
b[",i,"]*=d\
}"].join(""))
}

@@ -179,0 +177,0 @@ code.push(["return new ", className, "(this.data,a,b,c)}"].join(""))

{
"name": "ndarray",
"version": "1.0.2",
"version": "1.0.3",
"description": "Multidimensional Arrays",

@@ -5,0 +5,0 @@ "main": "ndarray.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc