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

ndarray

Package Overview
Dependencies
Maintainers
6
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.17 to 1.0.18

92

ndarray.js
var iota = require("iota-array")
var isBuffer = require("is-buffer")
var arrayMethods = [
"concat",
"join",
"slice",
"toString",
"indexOf",
"lastIndexOf",
"forEach",
"every",
"some",
"filter",
"map",
"reduce",
"reduceRight"
]
var hasTypedArrays = ((typeof Float64Array) !== "undefined")

@@ -106,18 +90,15 @@

var index_str = "this.offset+" + indices.map(function(i) {
return "this._stride" + i + "*i" + i
return "this.stride[" + i + "]*i" + i
}).join("+")
code.push("function "+className+"(a,"+
indices.map(function(i) {
var shapeArg = indices.map(function(i) {
return "b"+i
}).join(",") + "," +
indices.map(function(i) {
}).join(",")
var strideArg = indices.map(function(i) {
return "c"+i
}).join(",") + ",d){this.data=a")
for(var i=0; i<dimension; ++i) {
code.push("this._shape"+i+"=b"+i+"|0")
}
for(var i=0; i<dimension; ++i) {
code.push("this._stride"+i+"=c"+i+"|0")
}
code.push("this.offset=d|0}",
}).join(",")
code.push(
"function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a",
"this.shape=[" + shapeArg + "]",
"this.stride=[" + strideArg + "]",
"this.offset=d|0}",
"var proto="+className+".prototype",

@@ -127,38 +108,5 @@ "proto.dtype='"+dtype+"'",

//view.stride and view.shape
var strideClassName = "VStride" + dimension + "d" + dtype
var shapeClassName = "VShape" + dimension + "d" + dtype
var props = {"stride":strideClassName, "shape":shapeClassName}
for(var prop in props) {
var arrayName = props[prop]
code.push(
"function " + arrayName + "(v) {this._v=v} var aproto=" + arrayName + ".prototype",
"aproto.length="+dimension)
var array_elements = []
for(var i=0; i<dimension; ++i) {
array_elements.push(["this._v._", prop, i].join(""))
}
code.push(
"aproto.toJSON=function " + arrayName + "_toJSON(){return [" + array_elements.join(",") + "]}",
"aproto.valueOf=aproto.toString=function " + arrayName + "_toString(){return [" + array_elements.join(",") + "].join()}")
for(var i=0; i<dimension; ++i) {
code.push("Object.defineProperty(aproto,"+i+",{get:function(){return this._v._"+prop+i+"},set:function(v){return this._v._"+prop+i+"=v|0},enumerable:true})")
}
for(var i=0; i<arrayMethods.length; ++i) {
if(arrayMethods[i] in Array.prototype) {
code.push("aproto."+arrayMethods[i]+"=Array.prototype."+arrayMethods[i])
}
}
code.push(["Object.defineProperty(proto,'",prop,"',{get:function ", arrayName, "_get(){return new ", arrayName, "(this)},set: function ", arrayName, "_set(v){"].join(""))
for(var i=0; i<dimension; ++i) {
code.push("this._"+prop+i+"=v["+i+"]|0")
}
code.push("return v}})")
}
//view.size:
code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\
return "+indices.map(function(i) { return "this._shape"+i }).join("*"),
return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"),
"}})")

@@ -174,6 +122,6 @@

if(dimension === 2) {
code.push("return (Math.abs(this._stride0)>Math.abs(this._stride1))?[1,0]:[0,1]}})")
code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})")
} else if(dimension === 3) {
code.push(
"var s0=Math.abs(this._stride0),s1=Math.abs(this._stride1),s2=Math.abs(this._stride2);\
"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\
if(s0>s1){\

@@ -224,11 +172,11 @@ if(s1>s2){\

indices.map(function(i) {
return ["(typeof i",i,"!=='number'||i",i,"<0)?this._shape", i, ":i", i,"|0"].join("")
return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("")
}).join(",")+","+
indices.map(function(i) {
return "this._stride"+i
return "this.stride["+i + "]"
}).join(",")+",this.offset)}")
//view.lo():
var a_vars = indices.map(function(i) { return "a"+i+"=this._shape"+i })
var c_vars = indices.map(function(i) { return "c"+i+"=this._stride"+i })
var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" })
var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" })
code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","))

@@ -253,6 +201,6 @@ for(var i=0; i<dimension; ++i) {

indices.map(function(i) {
return "a"+i+"=this._shape"+i
return "a"+i+"=this.shape["+i+"]"
}).join(",")+","+
indices.map(function(i) {
return "b"+i+"=this._stride"+i
return "b"+i+"=this.stride["+i+"]"
}).join(",")+",c=this.offset,d=0,ceil=Math.ceil")

@@ -294,3 +242,3 @@ for(var i=0; i<dimension; ++i) {

for(var i=0; i<dimension; ++i) {
code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this._stride"+i+"*i"+i+")|0}else{a.push(this._shape"+i+");b.push(this._stride"+i+")}")
code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}")
}

@@ -297,0 +245,0 @@ code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}")

{
"name": "ndarray",
"version": "1.0.17",
"version": "1.0.18",
"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