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

arraytrans

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arraytrans

Do complex array transformation based on substrings to change order of array or remove values

  • 0.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Array Transform

Description: This module is used to do complex array transformations based on substrings to change the order of an array or remove values.

npm install arraytrans --save


var arrayTrans = require('arraytrans')

Methods:

order: Use this method to sort/order an array based on substrings.

remove: use this method to include or exclude elements of the array based on substrings.	

Order Method requires:

1.The array to transform.
2.Array of substrings in proper order.
3.Base string the substrings will be pulled from.
4.Location you want values that do not include base string(start or end or null). If null will try best to reconstruct close to original array.

Remove Method requires:

1.The array to transform.
2.Object that has include or exclude array.** Only pass one.
3.String base. This is used to delete from only a section of an array based on the string.

###example:

var testArr = 
['basestring.arrayone.one',
'nobase1',
'basestring.arrayone.two',
'nobase2',
'basestring.arrayone.three',
'basestring.arraytwo.one',
'basestring.arraytwo.two',
'basestring.arraytwo.three',
'basestring.arraythree.one',
'basestring.arraythree.two',
'basestring.araythree.three'];


console.log(arrayTrans.order(testArr,['arraytwo','arrayone','arraythree'],'basestring','start'));	

//OUTPUT=========================

[ 'nobase1',
'nobase2',
'basestring.arraytwo.three',
'basestring.arraytwo.two',
'basestring.arraytwo.one',
'basestring.arrayone.three',
'basestring.arrayone.two',
'basestring.arrayone.one',
'basestring.arraythree.two',
'basestring.arraythree.one',
'basestring.araythree.three' ]

=================================

console.log(arrayTrans.remove(testArr,{include:['basestring.arrayone.one']},'basestring.arrayone'));

//OUTPUT=========================

[ 'basestring.arrayone.one',
'nobase1',
'nobase2',
'basestring.arraytwo.one',
'basestring.arraytwo.two',
'basestring.arraytwo.three',
'basestring.arraythree.one',
'basestring.arraythree.two',
 'basestring.araythree.three' ]
 
 =================================
 
  	console.log(arrayTrans.remove(testArr,{exclude:['basestring.arrayone.one','basestring.arraythree.one']},'basestring'));

//OUTPUT=========================

[ 'nobase1',
'basestring.arrayone.two',
'nobase2',
'basestring.arrayone.three',
'basestring.arraytwo.one',
'basestring.arraytwo.two',
'basestring.arraytwo.three',
'basestring.arraythree.two',
'basestring.araythree.three' ]

=================================

Keywords

FAQs

Package last updated on 30 Dec 2015

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