0.0.1 • Published 3 years ago

nv-array-index-pattern v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

nv-array-index-pattern

  • nv-array-index-pattern

install

  • npm install nv-array-index-pattern

usage

  const {zip} = require("nv-array-index-pattern")

example

 var ary  = ['A','B','C','D','E','F']
 var ptrn = [0,[[1]],[2,[4,5],3]]
 var zipped = zip(ary,ptrn);


> zipped
[ 'A', [ [ 'B' ] ], [ 'C', [ 'E', 'F' ], 'D' ] ]
>
> ary
[ 'A', 'B', 'C', 'D', 'E', 'F' ]
> ptrn
[ 0, [ [ 1 ] ], [ 2, [ 4, 5 ], 3 ] ]
>




var ary = ['please','give','it','to','me']

> zip(ary,[3,4,1,2,0])
[ 'to', 'me', 'give', 'it', 'please' ]
>
> zip(ary,[2,4,0,1])
[ 'it', 'me', 'please', 'give' ]
>
> zip(ary,[[[0]],[1],[[2]],[[3],[[4]]]])
[
  [ [ 'please' ] ],
  [ 'give' ],
  [ [ 'it' ] ],
  [ [ 'to' ], [ [Array] ] ]
]
>

API

  • zip(ary,ptrn)

LICENSE

  • ISC