π UArray π
Provides UArray
, an Array
type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray()
or pass the elements directly to UArray()
and you are all set!
β Uses the built-inProxy
object, check browser compatibility on the Can I Use website.
Usage
v.1.1.0
the function signature has been changed and now it supports 2 different ways of action. You can now pass a single parameter of type Array
or multiple parameters of any primitive type.
Install it first by doing,
npm i "@igor.dvlpr/uarray"
and then use it,
const UArray = require('@igor.dvlpr/uarray')
const food = UArray(['π', 'π', 'πΏ', 'π₯', 'π₯']) // array passed
const objects = UArray('π', 'π©', 'β½', 'π₯', 'π―') // no array passed, just direct values
console.log(food[-1]) // prints 'π₯'
console.log(food[-3]) // prints 'πΏ'
console.log(objects[-1]) // prints 'π―'
console.log(objects[-3]) // prints 'β½'
π Happy coding!π