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

arc-object

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arc-object - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

__tests__/constant.js

74

index.js

@@ -96,2 +96,3 @@ "use strict";

//Implementation closer to array.map
map(_f, _asArray){

@@ -117,2 +118,20 @@ if(is(_f) !== 'function'){

//Implementation closer array.filter
filter(_f){
if(is(_f) !== 'function'){
throw new TypeError('ArcObject.filter argument must be a valid function');
}
const $this = this;
const keys = Object.keys(this);
const returnObj = {};
for(let i=0;i<keys.length;i++) {
const key = keys[i];
if(_f.call($this,this[key],key)){
returnObj[key] = this[key];
}
}
return returnObj;
}
//Lazy

@@ -185,57 +204,2 @@ count(){

//Remove values that evaluate to true through ArcCheck
filterVals(_Check){
if(is(_Check,true) !== 'ArcCheck'){
throw new TypeError('ArcObject.filterVals expects a valid ArcCheck object as an argument');
}
const $this = this;
const keys = $this.keys();
for(let i=0;i<keys.length;i++){
let key = keys[i];
if(_Check.val($this[key])){
delete $this[key];
}
}
return $this;
}
//Remove values that have keys that evaluate to true through ArcCheck
filterKeys(_Check){
if(is(_Check,true) !== 'ArcCheck'){
throw new TypeError('ArcObject.filterKeys expects a valid /Arc/Filter object as an argument');
}
const $this = this;
const keys = $this.keys();
keys.forEach(function(_key){
if(_Check.val(_key)){
delete $this[_key];
}
});
return $this;
}
//Remove values that have values that match a value of the filterArray
quickFilterVals(_filterArray){
if(is(_filterArray) !== 'array'){
throw new TypeError('ArcObject.quickFilterVals expects a valid array of values to check against');
}
const C = new Check();
C.addInclude(function(_val){
return (_filterArray.indexOf(_val) !== -1 ? true : false);
});
return this.filterVals(C);
}
//Remove values that have keys that match a value of the filterArray
quickFilterKeys(_filterArray){
if(is(_filterArray) !== 'array'){
throw new TypeError('ArcObject.quickFilterKeys expects a valid array of values to check against');
}
const C = new Check();
C.addInclude(function(_val){
return (_filterArray.indexOf(_val) !== -1 ? true : false);
});
return this.filterKeys(C);
}
constant(_key,_val,_enumerable){

@@ -242,0 +206,0 @@ ArcObject.defineConstant(this,_key,_val,_enumerable);

{
"name": "arc-object",
"version": "3.0.0",
"version": "3.1.0",
"description": "An object convenience subclass",
"main": "index.js",
"scripts": {
"test": "tap test/*.js --coverage --coverage-report=html"
"test": "jest"
},

@@ -30,4 +30,4 @@ "repository": {

"devDependencies": {
"tap": "^14.2.2"
"jest": "^24.8.0"
}
}

@@ -11,4 +11,2 @@ # arc-object [![Build Status](https://travis-ci.org/anyuzer/arc-object.svg?branch=master)](https://travis-ci.org/anyuzer/arc-object)

* forEach() with break functionality
* complex key/value filtering (using ArcCheck)
* quick filtering
* fauxrray like functions

@@ -24,2 +22,3 @@ * ksort()

* map()
* filter()
* deepGet() to safely look for and return a value from a nested structure

@@ -187,13 +186,10 @@ * native convenience binding (if desired)

### .quickFilterKeys(values:Array) / .quickFilterVals(values:Array)
Remove indexes from object based on either matching keys, or matching values.
### .filter(callback:Function)
Remove indexes from object based on callback return of false
```js
//Example of quickFilter
//Example of filter
var alpha = new ArcObject({a:true,b:false,z:undefined});
alpha.quickFilterVals([false,undefined]); //Object is reduced to {a:'a'}
alpha.filter(val => !!val); //Object is reduced to {a:true}
```
### .filterKeys(filter:ArcCheck) / .filterVals(filter:ArcCheck)
Use an ArcCheck object to perform complex evaluation on a key or value to decide whether or not it should be removed from the object (see ArcCheck for more details on use).
### ArcObject.deepGet(...args)

@@ -200,0 +196,0 @@ This is method that can be used to safely fetch a nested key path inside of an object. Returns the value found, or undefined

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