Socket
Socket
Sign inDemoInstall

array-portal

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-portal

Make a portal between two arrays and transfer items between them


Version published
Maintainers
1
Created
Source

Array Portal

Make a portal between two arrays and transfer items between them

Build Status devDependency Status Dependency Status

Install

$ npm install array-portal --save

Usage

// 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']
// }

Complex callers

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!'
//   }]

Benchmark

110,029 op/s

Contribute

// 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

Keywords

FAQs

Package last updated on 22 Apr 2016

Did you know?

Socket

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.

Install

Related posts

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