Comparing version 3.2.2 to 4.0.0
109
index.js
@@ -1,111 +0,4 @@ | ||
"use strict"; | ||
var is = require('arc-is'); | ||
var Check = require('arc-check'); | ||
const is = require('arc-is'); | ||
class ArcArray extends Array { | ||
//Pretty much a polyfill of forEach, except here I replaced the array reference (3rd arg) with a break function. | ||
//(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) | ||
each(_f,_thisArg){ | ||
if(is(_f) !== "function") { | ||
throw new TypeError('argument is not a function'); | ||
} | ||
//Declare | ||
var $this,key,length,Obj; | ||
//Our contextual this (for the callback) | ||
$this = _thisArg || this; | ||
//Readibly polyfillian | ||
key = 0; | ||
Obj = Object(this); | ||
length = Obj.length >>> 0; | ||
//Iterate (obviously) | ||
while(key<length){ | ||
let val; | ||
if(key in Obj){ | ||
val = Obj[key]; | ||
if(_f.call($this,key,val,this) === false){ | ||
break; | ||
} | ||
} | ||
key++; | ||
} | ||
} | ||
returnEach(_f,_returnArg,_falseBreak){ | ||
if(is(_f) !== "function") { | ||
throw new TypeError('argument is not a function'); | ||
} | ||
_falseBreak = (_falseBreak === false ? false : true); | ||
//Declare | ||
var $this,key,length,Obj; | ||
//Our contextual this (for the callback) | ||
$this = this; | ||
//Readibly polyfillian | ||
key = 0; | ||
Obj = Object(this); | ||
length = Obj.length >>> 0; | ||
//Iterate (obviously) | ||
while(key<length){ | ||
let val,cbReturn; | ||
if(key in Obj){ | ||
val = Obj[key]; | ||
cbReturn = _f.call($this,key,val,_returnArg); | ||
if(cbReturn === false && _falseBreak){ | ||
break; | ||
} | ||
_returnArg = cbReturn || _returnArg; | ||
} | ||
key++; | ||
} | ||
return _returnArg; | ||
} | ||
//Truthy/falsy indexOf | ||
contains(_value){ | ||
return (this.indexOf(_value) === -1 ? false : true); | ||
} | ||
//If a value in the array checks true, it will be removed | ||
filter(_Check){ | ||
if(is(_Check,true) !== 'ArcCheck'){ | ||
throw new TypeError('ArcArray.filter expects a valid ArcCheck object to check against'); | ||
} | ||
var $this,its,index; | ||
$this = this; | ||
its = this.length; | ||
index = 0; | ||
for(var i=0;i<its;i++){ | ||
if(_Check.val($this[index])){ | ||
$this.splice(index,1); | ||
} | ||
else{ | ||
index++; | ||
} | ||
} | ||
return this; | ||
} | ||
//Pass an array in [false,undefined,"SEVEN"] and any index that has a value that matches one of these will be removed | ||
quickFilter(_excludeVals){ | ||
if(is(_excludeVals) !== 'array'){ | ||
throw new TypeError('ArcArray.quickFilter expects a valid array of values to check against'); | ||
} | ||
var C = new Check(); | ||
C.addInclude(function(_val){ | ||
//This will be called against the values, if the value exists it 'can' have it, we return true, so the check will pass, telling us we want to remove it. | ||
return (_excludeVals.indexOf(_val) !== -1 ? true : false); | ||
}); | ||
return this.filter(C); | ||
} | ||
//Iterate through the array, call the callback passing in the value join the returned values (I may want to check to see if the return val is a string?) | ||
@@ -112,0 +5,0 @@ joinCallback(_callback,_separator){ |
{ | ||
"name": "arc-array", | ||
"version": "3.2.2", | ||
"version": "4.0.0", | ||
"description": "An array convenience subclass", | ||
@@ -23,3 +23,2 @@ "main": "index.js", | ||
"dependencies": { | ||
"arc-check": "^1.0.2", | ||
"arc-is": "1.0.5" | ||
@@ -26,0 +25,0 @@ }, |
@@ -17,3 +17,6 @@ var tap = require('tap'); | ||
const sameArray = testArray.arc(); | ||
_test.equal(sameArray,testArray); | ||
_test.end(); | ||
}); |
@@ -1,4 +0,4 @@ | ||
var tap = require('tap'); | ||
var is = require('arc-is'); | ||
var ArcArray = require('../'); | ||
const tap = require('tap'); | ||
const is = require('arc-is'); | ||
const ArcArray = require('../'); | ||
@@ -16,3 +16,10 @@ //Test native casting, and toString | ||
_test.equal(wrapResult,ArcArray.wrap(wrapResult)); | ||
const testArray2 = ['a']; | ||
wrapResult = ArcArray.wrap(testArray2); | ||
_test.equal(is(wrapResult,true),'ArcArray'); | ||
_test.same(testArray2,wrapResult); | ||
_test.equal(wrapResult,ArcArray.wrap(wrapResult)); | ||
_test.end(); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
1
9799
9
125
1
- Removedarc-check@^1.0.2
- Removedarc-check@1.2.1(transitive)
- Removedarc-is@1.0.8(transitive)