Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
array-walker
Advanced tools
Traverses a multi-dimensional array and fires off a callback with a value and its relationship.
let walker = require('array-walker');
// A single-dimensional array
walker(['a', 'b'], (value, key) => console.log(value, key));
// a, 0
// b, 1
// A two-dimensional array
walker([['a', 'b'], ['c', 'd']], (value, x, y) => console.log(value, x, y));
// a, 0, 0
// b, 0, 1
// c, 1, 0
// d, 1, 1
// A 12-dimensional array
walker(
[[[[[[[[[[[['a', 'b']]]]]], 'c']]]]]],
(value, ...lineage) => console.log(value, ...lineage)
);
// a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
// c, 0, 0, 0, 0, 0, 1
// With context
walker(['a', 'b'], callbackWithContext, {example: "The Answer"});
// The Answer, a, 0
// The Answer, b, 1
function callbackWithContext(value, key) {
console.log(this.example, value, key);
}
$ npm install array-walker
var walker = require('array-walker');
Type | Data Type | Name | Description |
---|---|---|---|
parameter | *[] | items | The array to walk. |
parameter | function | observationCallback | The function to call when a non-array value is found. |
parameter | * | The context passed to the callback | |
parameter | ...number | [lineage] | The parent indexes. |
returns | undefined | n/a | n/a |
The observation callback is fired when a non-array value is found.
Type | Data Type | Name | Description |
---|---|---|---|
this | * | this | The context passed to the walker |
parameter | !*[] | value | The value that was discovered. |
parameter | ...number | lineage | The indexes in each dimension of the array. |
returns | undefined | n/a | n/a |
FAQs
Multi-dimensional array walker with observation
We found that array-walker 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.