stahr-tools
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -120,2 +120,3 @@ const ArrayTools = {} | ||
return newArray | ||
} | ||
@@ -122,0 +123,0 @@ |
{ | ||
"name": "stahr-tools", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "release.js", |
@@ -1,1 +0,1 @@ | ||
const ArrayTools={};ArrayTools.Remove=function(o,r){let n=o.indexOf(r);return n>-1&&o.splice(n,1),o},ArrayTools.RemoveByIndex=function(o,r){return r>-1&&o.splice(r,1),o},ArrayTools.ChooseRandom=function(o){return o[Math.floor(Math.random()*o.length)]},ArrayTools.ArrayToTable=function(o){let r={};for(let n=0;n<o.length;n++)r[o[n]]=!0;return r},ArrayTools.TableToArray=function(o){let r=[];for(let n in o)r.push(n);return r},ArrayTools.InvertArray=function(o){let r=[];for(let n=o.length-1;n>=0;n--)r.push(o[n]);return r},ArrayTools.InvertTable=function(o){let r={};for(let n in o)r[o[n]]=n;return r},ArrayTools.Shuffle=function(o){let r=o.length,n,t;for(;0!==r;)t=Math.floor(Math.random()*r),r-=1,n=o[r],o[r]=o[t],o[t]=n;return o},ArrayTools.ChooseRandomMultiple=function(o,r){let n=[];for(let t=0;t<r;t++)n.push(o[Math.floor(Math.random()*o.length)])};const ObjectTools={};ObjectTools.Clone=function(o){return JSON.parse(JSON.stringify(o))},ObjectTools.Merge=function(o,r){for(let n in r)o[n]=r[n];return o};const StringTools={};StringTools.Split=function(o,r){return o.split(r)},StringTools.Join=function(o,r){return o.join(r)},StringTools.Trim=function(o){return o.trim()},exports.ArrayTools=ArrayTools,exports.ObjectTools=ObjectTools; | ||
const ArrayTools={Remove:function(array,item){const index=array.indexOf(item);return index>-1&&array.splice(index,1),array},RemoveByIndex:function(array,index){return index>-1&&array.splice(index,1),array},ChooseRandom:function(array){return array[Math.floor(Math.random()*array.length)]},ArrayToTable:function(array){const table={};for(let i=0;i<array.length;i++)table[array[i]]=!0;return table},TableToArray:function(table){const array=[];for(const key in table)array.push(key);return array},InvertArray:function(array){const inverted=[];for(let i=array.length-1;i>=0;i--)inverted.push(array[i]);return inverted},InvertTable:function(table){const inverted={};for(const key in table)inverted[table[key]]=key;return inverted},Shuffle:function(array){let currentIndex=array.length,temporaryValue,randomIndex;for(;0!==currentIndex;)randomIndex=Math.floor(Math.random()*currentIndex),currentIndex-=1,temporaryValue=array[currentIndex],array[currentIndex]=array[randomIndex],array[randomIndex]=temporaryValue;return array},ChooseRandomMultiple:function(array,count){const newArray=[];for(let i=0;i<count;i++)newArray.push(array[Math.floor(Math.random()*array.length)]);return newArray}},ObjectTools={Clone:function(object){return JSON.parse(JSON.stringify(object))},Merge:function(object1,object2){for(const key in object2)object1[key]=object2[key];return object1}},StringTools={Split:function(string,separator){return string.split(separator)},Join:function(array,separator){return array.join(separator)},Trim:function(string){return string.trim()}};exports.ArrayTools=ArrayTools,exports.ObjectTools=ObjectTools; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4524
84