Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
array-portal
Advanced tools
Make a portal between two arrays and transfer items between them
$ npm install array-portal --save
// Import with ES6
import ArrayPortal from 'array-portal';
// Import with ES5
var ArrayPortal = require('array-portal').default;
ArrayPortal({
caller: 'a'
input: ['a','b','c'],
output: ['d','e']
})
// Returns:
// {
// input: ['b','c'],
// output: ['a','d','e']
// }
If you pass an object to the caller the ArrayPortal uses the lodash findIndex method to handle the search-stuff. So you can pass whatever you want in the object, the findIndex module manage this. :warning: You can just pass objects through the caller, the findIndex method from lodash accepts more types - this module ignores everything except objects. Fore more information checkout the findIndex Documentation on the loadash.com
ArrayPortal({
caller: {
id: 123
},
input: [{
id: 3,
title: 'foobar'
},{
id: 39,
title: 'nom nom nom'
},{
id: 123,
title: 'Portal it baby!'
}],
output: [{
id: 1337,
title: 'my door is open dude'
}]
});
// returns:
// input: [{
// id: 3,
// title: 'foobar'
// },{
// id: 39,
// title: 'nom nom nom'
// }],
// output: [{
// id: 1337,
// title: 'my door is open dude',
// },{
// id: 123,
// title: 'Portal it baby!'
// }]
110,029 op/s
// Run and Watch tests
$ npm run test -- -w
// Just run tests
$ npm run test
// Create new build
$ npm run build
// Run benchmark
$ npm run bench
FAQs
Make a portal between two arrays and transfer items between them
We found that array-portal 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.