![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
arc-object
Advanced tools
An object convenience subclass for javascript (ES6)
$ npm install arc-object --save
The following example creates a new ArcObject, filters out false/empty/null values, keysorts, and breaks on a specific value
var ArcObject = require('arc-object');
var alpha = new ArcObject({z:'z',x:false,y:'aardvark',a:'a',b:undefined,c:'c'});
//Filter out false/undefined vals
alpha.quickFilterVals([false,undefined]);
//Key sort. Now internally ordered as {a:'a',c:'c',y:'aardvark',z:'z'}
alpha.ksort();
//Iterate
alpha.each(function(_key,_val){
if(_val === 'aardvark'){
//Break when we hit aardvark
return false;
}
});
Create a new ArcObject
object. Requires new
Loop over an object index, calling callback each iteration. Break when false
is explicitly returned.
callback is a required function that is called with 3 arguments passed in
thisContext is an optional object that will be available inside of the callback as this
if set, otherwise defaulting to the original object.
//Example of breaking each
var users = new ArcObject({'a':'aardvark','b':'brad','c':'documents are boring'});
users.each(function(_k,_v){
if(_v === 'brad'){
return false;
}
});
Like .each except takes in an argument, passes it into each callback, and mutates it accordingly based on whether or not anything was returned.
By default, returning false breaks the iteration, but this can be optionally switched off by passing in false as the third argument.
//Example of returning returnEach
var users = new ArcObject({'a':'aardvark','b':'brad','c':'documents are boring','d':'Andy'});
var aUsers = users.returnEach(function(_key,_val,_aUsers){
if(_val.charAt(0) === 'a'){
_aUsers.push(_val);
}
return _aUsers;
},[]);
//aUsers contains ['aardvark','Andy']
Rebuild an object by keys (alphabetical)
var alpha = new ArcObject({c:'c',b:'b',a,'a'});
alpha.ksort(); //Now {a:'a',b:'b',c:'c'}
Get whatever value is currently at the first pointer in the object index
var alpha = new ArcObject({a:'a',z:'z'});
alpha.first(); //return 'a'
Get whatever value is currently at the last pointer in the object index
var alpha = new ArcObject({a:'a',z:'z'});
alpha.first(); //return 'z'
Remove and return whatever value is currently at the first pointer in the object index
var alpha = new ArcObject({a:'a',z:'z'});
alpha.shift(); //return 'a' and remove 'a' from alpha object
Remove and return whatever value is currently at the last pointer in the object index
var alpha = new ArcObject({a:'a',z:'z'});
alpha.pop(); //return 'z' and remove 'z' from alpha object
Return the current length of the object utilizing Object.keys(this).length
var alpha = new ArcObject({a:'a',z:'z'});
alpha.count(); //return 2
Return an ArcArray array of the current object keys
var alpha = new ArcObject({a:'a',z:'z'});
alpha.keys(); //['a','z'] (ArcArray)
Turn object immutable (shallow)
var alpha = new ArcObject({a:'a',z:'z'});
alpha.freeze();
alpha.a = 'aardvark'; //This will fail to set the a property
Turn object immutable (deep)
var alpha = new ArcObject({a:'a',z:{x:'x'}});
alpha.deepFreeze();
alpha.z.x = 'aardvark'; //This will fail to set the a property
Remove indexes from object based on either matching keys, or matching values.
//Example of quickFilter
var alpha = new ArcObject({a:true,b:false,z:undefined});
alpha.quickFilterVals([false,undefined]); //Object is reduced to {a:'a'}
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).
This is a static method that can be used to check whether or not an object chain has been instantiated.
//An descriptive object with sub data
var user = {'details':{'id':false,'address':undefined}};
ArcObject.check(user,user.details); //Returns true
ArcObject.check(user,user.details,user.details.address); //Returns false
this is a static method that binds a method to the native global object property that transforms an object into an ArcObject object. This has a global effect and should be used carefully.
ArcObject.nativeBind();
var users = {
id1:'aaa',
id2:'bbb',
id3:'ccc'
}.arc(); //This returns an ArcObject object
npm test
FAQs
An object convenience subclass
The npm package arc-object receives a total of 839 weekly downloads. As such, arc-object popularity was classified as not popular.
We found that arc-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.