Socket
Socket
Sign inDemoInstall

@basementuniverse/commonjs

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.8 to 1.2.9

10

common.d.ts

@@ -211,3 +211,11 @@ /// <reference types="typescript" />

*/
range(n: number): Array<number>
range(n: number): Array<number>,
/**
* Zip 2 arrays together, i.e. ([1, 2, 3], [a, b, c]) => [[1, a], [2, b], [3, c]]
* @param {Array<*>} a
* @param {Array<*>} b
* @return {Array<*>}
*/
zip(a: Array<any>, b: Array<any>): Array<Array<*>>
}

@@ -214,0 +222,0 @@

/**
* @overview A library of useful functions
* @author Gordon Larrigan
* @version 1.2.8
* @version 1.2.9
*/

@@ -235,2 +235,10 @@

/**
* Zip 2 arrays together, i.e. ([1, 2, 3], [a, b, c]) => [[1, a], [2, b], [3, c]]
* @param {Array<*>} a
* @param {Array<*>} b
* @return {Array<Array<*>>}
*/
Array.zip = (a, b) => a.map((k, i) => [k, b[i]]);
/**
* Return array[i] with positive and negative wrapping

@@ -237,0 +245,0 @@ * @name at

2

common.min.js

@@ -1,1 +0,1 @@

Math.floatEquals=(t,a,e=Number.EPSILON)=>Math.abs(t-a)<e,Math.clamp=(t,a=0,e=1)=>t<a?a:t>e?e:t,Math.frac=t=>t>=0?t-Math.floor(t):t-Math.ceil(t),Math.lerp=(t,a,e)=>t+(a-t)*e,Math.unlerp=(t,a,e)=>(e-t)/(a-t),Math.blerp=(t,a,e,r,n,m)=>Math.lerp(Math.lerp(t,a,n),Math.lerp(e,r,n),m),Math.remap=(t,a,e,r,n)=>r+(t-a)*(n-r)/(e-a),Math.smoothstep=(t,a,e)=>Math.lerp(t,a,3*Math.pow(e,2)-2*Math.pow(e,3)),Math.radians=t=>Math.PI/180*t,Math.degrees=t=>180/Math.PI*t,Math.randomBetween=(t,a)=>Math.random()*(a-t)+t,Math.randomIntBetween=(t,a)=>Math.floor(Math.random()*(a-t+1))+t,Math.cltRandom=(t=.5,a=.5,e=2)=>{let r=0;for(let t=e;t--;)r+=Math.random();return t+(r-e/2)/(e/2)*a},Math.cltRandomInt=(t,a)=>Math.floor(t+Math.cltRandom(.5,.5,2)*(a+1-t)),Math.weightedRandom=t=>{let a=t.reduce(((t,a)=>t+a),0),e=0;const r=Math.random()*a;for(;a>r;)a-=t[e++];return e-1},Math.lerpArray=(t,a,e=Math.lerp)=>{const r=a*(t.length-1),n=Math.clamp(Math.trunc(r),0,t.length-1);return e(t[n]||0,t[n+1]||0,Math.frac(r))},Math.dot=(t,a)=>t.reduce(((t,e,r)=>t+e*a[r]),0),Math.factorial=t=>{let a=1;for(let e=2;e<=t;e++)a*=e;return a},Math.permutation=(t,a)=>Math.factorial(t)/Math.factorial(t-a),Math.combination=(t,a)=>Math.factorial(t)/(Math.factorial(a)*Math.factorial(t-a)),Array.times=(t,a)=>Array(a).fill(0).map(((a,e)=>t(e))),Array.range=t=>Array.times((t=>t),t),Object.defineProperty(Array.prototype,"at",{value:function(t){const a=this.length;return this[t<0?a-Math.abs(t+1)%a-1:t%a]}}),Object.defineProperty(Array.prototype,"chunk",{value:function(t){return Array.times((a=>this.slice(a*t,a*t+t)),Math.ceil(this.length/t))}}),Object.defineProperty(Array.prototype,"shuffle",{value:function(){return this.map((t=>[Math.random(),t])).sort(((t,a)=>t[0]-a[0])).map((t=>t[1]))}});const vec=(t,a)=>t||a?"object"==typeof t?{x:t.x||0,y:t.y||0}:null==a?{x:t,y:t}:{x:t,y:a}:{x:0,y:0};vec.components=t=>[t.x,t.y],vec.ux=()=>vec(1,0),vec.uy=()=>vec(0,1),vec.add=(t,a)=>({x:t.x+a.x,y:t.y+a.y}),vec.mul=(t,a)=>({x:t.x*a,y:t.y*a}),vec.sub=(t,a)=>({x:t.x-a.x,y:t.y-a.y}),vec.len=t=>Math.sqrt(t.x*t.x+t.y*t.y),vec.manhattan=t=>Math.abs(t.x)+Math.abs(t.y),vec.nor=t=>{let a=vec.len(t);return a?{x:t.x/a,y:t.y/a}:vec()},vec.dot=(t,a)=>t.x*a.x+t.y*a.y,vec.rot=(t,a)=>{let e=Math.sin(a),r=Math.cos(a);return{x:r*t.x-e*t.y,y:e*t.x+r*t.y}},vec.eq=(t,a)=>t.x===a.x&&t.y===a.y,vec.rad=t=>Math.atan2(t.y,t.x),vec.cpy=t=>vec(t),vec.map=(t,a)=>({x:a(t.x,"x"),y:a(t.y,"y")}),vec.str=(t,a=", ")=>`${t.x}${a}${t.y}`;const mat=(t=4,a=4,e=[])=>({m:t,n:a,entries:e.concat(Array(t*a).fill(0)).slice(0,t*a)});mat.identity=t=>mat(t,t,Array(t*t).fill(0).map(((a,e)=>+(Math.floor(e/t)===e%t)))),mat.get=(t,a,e)=>t.entries[e-1+(a-1)*t.n],mat.set=(t,a,e,r)=>{t.entries[e-1+(a-1)*t.n]=r},mat.row=(t,a)=>{const e=(a-1)*t.n;return t.entries.slice(e,e+t.n)},mat.col=(t,a)=>Array.times((e=>mat.get(t,e+1,a)),t.m),mat.add=(t,a)=>t.m===a.m&&t.n===a.n&&mat.map(t,((t,e)=>t+a.entries[e])),mat.sub=(t,a)=>t.m===a.m&&t.n===a.n&&mat.map(t,((t,e)=>t-a.entries[e])),mat.mul=(t,a)=>{if(t.n!==a.m)return!1;const e=mat(t.m,a.n);for(let r=1;r<=t.m;r++)for(let n=1;n<=a.n;n++)mat.set(e,r,n,Math.dot(mat.row(t,r),mat.col(a,n)));return e},mat.scale=(t,a)=>mat.map(t,(t=>t*a)),mat.trans=t=>mat(t.n,t.m,Array.times((a=>mat.col(t,a+1)),t.n).flat()),mat.minor=(t,a,e)=>{if(t.m!==t.n)return!1;const r=[];for(let n=1;n<=t.m;n++)if(n!==a)for(let a=1;a<=t.n;a++)a!==e&&r.push(mat.get(t,n,a));return mat(t.m-1,t.n-1,r)},mat.det=t=>{if(t.m!==t.n)return!1;if(1===t.m)return t.entries[0];if(2===t.m)return t.entries[0]*t.entries[3]-t.entries[1]*t.entries[2];let a=0,e=1;for(let r=1;r<=t.n;r++)a+=e*t.entries[r-1]*mat.det(mat.minor(t,1,r)),e*=-1;return a},mat.nor=t=>{if(t.m!==t.n)return!1;const a=mat.det(t);return mat.map(t,(t=>t*a))},mat.adj=t=>{const a=mat(t.m,t.n);for(let e=1;e<=t.m;e++)for(let r=1;r<=t.n;r++)mat.set(a,e,r,mat.det(mat.minor(t,e,r)));const e=mat.map(a,((t,a)=>t*(a%2?-1:1)));return mat.trans(e)},mat.inv=t=>{if(t.m!==t.n)return!1;const a=mat.det(t);return 0!==a&&mat.scale(mat.adj(t),1/a)},mat.eq=(t,a)=>t.m===a.m&&t.n===a.n&&mat.str(t)===mat.str(a),mat.cpy=t=>mat(t.m,t.n,[...t.entries]),mat.map=(t,a)=>mat(t.m,t.n,t.entries.map(a)),mat.str=(t,a=", ",e="\n")=>t.entries.chunk(t.n).map((t=>t.join(a))).join(e),"undefined"!=typeof module&&(module.exports={vec:vec,mat:mat});
Math.floatEquals=(t,a,e=Number.EPSILON)=>Math.abs(t-a)<e,Math.clamp=(t,a=0,e=1)=>t<a?a:t>e?e:t,Math.frac=t=>t>=0?t-Math.floor(t):t-Math.ceil(t),Math.lerp=(t,a,e)=>t+(a-t)*e,Math.unlerp=(t,a,e)=>(e-t)/(a-t),Math.blerp=(t,a,e,r,n,m)=>Math.lerp(Math.lerp(t,a,n),Math.lerp(e,r,n),m),Math.remap=(t,a,e,r,n)=>r+(t-a)*(n-r)/(e-a),Math.smoothstep=(t,a,e)=>Math.lerp(t,a,3*Math.pow(e,2)-2*Math.pow(e,3)),Math.radians=t=>Math.PI/180*t,Math.degrees=t=>180/Math.PI*t,Math.randomBetween=(t,a)=>Math.random()*(a-t)+t,Math.randomIntBetween=(t,a)=>Math.floor(Math.random()*(a-t+1))+t,Math.cltRandom=(t=.5,a=.5,e=2)=>{let r=0;for(let t=e;t--;)r+=Math.random();return t+(r-e/2)/(e/2)*a},Math.cltRandomInt=(t,a)=>Math.floor(t+Math.cltRandom(.5,.5,2)*(a+1-t)),Math.weightedRandom=t=>{let a=t.reduce(((t,a)=>t+a),0),e=0;const r=Math.random()*a;for(;a>r;)a-=t[e++];return e-1},Math.lerpArray=(t,a,e=Math.lerp)=>{const r=a*(t.length-1),n=Math.clamp(Math.trunc(r),0,t.length-1);return e(t[n]||0,t[n+1]||0,Math.frac(r))},Math.dot=(t,a)=>t.reduce(((t,e,r)=>t+e*a[r]),0),Math.factorial=t=>{let a=1;for(let e=2;e<=t;e++)a*=e;return a},Math.permutation=(t,a)=>Math.factorial(t)/Math.factorial(t-a),Math.combination=(t,a)=>Math.factorial(t)/(Math.factorial(a)*Math.factorial(t-a)),Array.times=(t,a)=>Array(a).fill(0).map(((a,e)=>t(e))),Array.range=t=>Array.times((t=>t),t),Array.zip=(t,a)=>t.map(((t,e)=>[t,a[e]])),Object.defineProperty(Array.prototype,"at",{value:function(t){const a=this.length;return this[t<0?a-Math.abs(t+1)%a-1:t%a]}}),Object.defineProperty(Array.prototype,"chunk",{value:function(t){return Array.times((a=>this.slice(a*t,a*t+t)),Math.ceil(this.length/t))}}),Object.defineProperty(Array.prototype,"shuffle",{value:function(){return this.map((t=>[Math.random(),t])).sort(((t,a)=>t[0]-a[0])).map((t=>t[1]))}});const vec=(t,a)=>t||a?"object"==typeof t?{x:t.x||0,y:t.y||0}:null==a?{x:t,y:t}:{x:t,y:a}:{x:0,y:0};vec.components=t=>[t.x,t.y],vec.ux=()=>vec(1,0),vec.uy=()=>vec(0,1),vec.add=(t,a)=>({x:t.x+a.x,y:t.y+a.y}),vec.mul=(t,a)=>({x:t.x*a,y:t.y*a}),vec.sub=(t,a)=>({x:t.x-a.x,y:t.y-a.y}),vec.len=t=>Math.sqrt(t.x*t.x+t.y*t.y),vec.manhattan=t=>Math.abs(t.x)+Math.abs(t.y),vec.nor=t=>{let a=vec.len(t);return a?{x:t.x/a,y:t.y/a}:vec()},vec.dot=(t,a)=>t.x*a.x+t.y*a.y,vec.rot=(t,a)=>{let e=Math.sin(a),r=Math.cos(a);return{x:r*t.x-e*t.y,y:e*t.x+r*t.y}},vec.eq=(t,a)=>t.x===a.x&&t.y===a.y,vec.rad=t=>Math.atan2(t.y,t.x),vec.cpy=t=>vec(t),vec.map=(t,a)=>({x:a(t.x,"x"),y:a(t.y,"y")}),vec.str=(t,a=", ")=>`${t.x}${a}${t.y}`;const mat=(t=4,a=4,e=[])=>({m:t,n:a,entries:e.concat(Array(t*a).fill(0)).slice(0,t*a)});mat.identity=t=>mat(t,t,Array(t*t).fill(0).map(((a,e)=>+(Math.floor(e/t)===e%t)))),mat.get=(t,a,e)=>t.entries[e-1+(a-1)*t.n],mat.set=(t,a,e,r)=>{t.entries[e-1+(a-1)*t.n]=r},mat.row=(t,a)=>{const e=(a-1)*t.n;return t.entries.slice(e,e+t.n)},mat.col=(t,a)=>Array.times((e=>mat.get(t,e+1,a)),t.m),mat.add=(t,a)=>t.m===a.m&&t.n===a.n&&mat.map(t,((t,e)=>t+a.entries[e])),mat.sub=(t,a)=>t.m===a.m&&t.n===a.n&&mat.map(t,((t,e)=>t-a.entries[e])),mat.mul=(t,a)=>{if(t.n!==a.m)return!1;const e=mat(t.m,a.n);for(let r=1;r<=t.m;r++)for(let n=1;n<=a.n;n++)mat.set(e,r,n,Math.dot(mat.row(t,r),mat.col(a,n)));return e},mat.scale=(t,a)=>mat.map(t,(t=>t*a)),mat.trans=t=>mat(t.n,t.m,Array.times((a=>mat.col(t,a+1)),t.n).flat()),mat.minor=(t,a,e)=>{if(t.m!==t.n)return!1;const r=[];for(let n=1;n<=t.m;n++)if(n!==a)for(let a=1;a<=t.n;a++)a!==e&&r.push(mat.get(t,n,a));return mat(t.m-1,t.n-1,r)},mat.det=t=>{if(t.m!==t.n)return!1;if(1===t.m)return t.entries[0];if(2===t.m)return t.entries[0]*t.entries[3]-t.entries[1]*t.entries[2];let a=0,e=1;for(let r=1;r<=t.n;r++)a+=e*t.entries[r-1]*mat.det(mat.minor(t,1,r)),e*=-1;return a},mat.nor=t=>{if(t.m!==t.n)return!1;const a=mat.det(t);return mat.map(t,(t=>t*a))},mat.adj=t=>{const a=mat(t.m,t.n);for(let e=1;e<=t.m;e++)for(let r=1;r<=t.n;r++)mat.set(a,e,r,mat.det(mat.minor(t,e,r)));const e=mat.map(a,((t,a)=>t*(a%2?-1:1)));return mat.trans(e)},mat.inv=t=>{if(t.m!==t.n)return!1;const a=mat.det(t);return 0!==a&&mat.scale(mat.adj(t),1/a)},mat.eq=(t,a)=>t.m===a.m&&t.n===a.n&&mat.str(t)===mat.str(a),mat.cpy=t=>mat(t.m,t.n,[...t.entries]),mat.map=(t,a)=>mat(t.m,t.n,t.entries.map(a)),mat.str=(t,a=", ",e="\n")=>t.entries.chunk(t.n).map((t=>t.join(a))).join(e),"undefined"!=typeof module&&(module.exports={vec:vec,mat:mat});
{
"name": "@basementuniverse/commonjs",
"version": "1.2.8",
"version": "1.2.9",
"description": "A collection of useful functions",

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

@@ -383,2 +383,3 @@ # common.js

* [.range(n)](#Array.range) ⇒ <code>Array.&lt;number&gt;</code>
* [.zip(a, b)](#Array.zip) ⇒ <code>Array.&lt;Array.&lt;\*&gt;&gt;</code>

@@ -440,2 +441,14 @@ <a name="Array+at"></a>

<a name="Array.zip"></a>
### Array.zip(a, b) ⇒ <code>Array.&lt;Array.&lt;\*&gt;&gt;</code>
Zip 2 arrays together, i.e. ([1, 2, 3], [a, b, c]) => [[1, a], [2, b], [3, c]]
**Kind**: static method of [<code>Array</code>](#Array)
| Param | Type |
| --- | --- |
| a | <code>Array.&lt;\*&gt;</code> |
| b | <code>Array.&lt;\*&gt;</code> |
<a name="vec"></a>

@@ -442,0 +455,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc