Skip to content

πŸŽ‰ Provides UArray, an Array type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray() and you are all set! πŸ™Œ

License

Notifications You must be signed in to change notification settings

igorskyflyer/npm-uarray

Repository files navigation

Icon of UArray

UArray


πŸŽ‰ Provides UArray, an Array type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray() and you are all set! πŸ™Œ



πŸ“ƒ Table of Contents



πŸ€– Features

  • πŸ”’ Negative indexing (-1, -2, etc.)
  • 🧳 Accepts array or multiple values
  • πŸͺž Behaves like a native array
  • πŸ› οΈ Supports all standard methods
  • 🧼 Safe fallback for non-numeric keys
  • πŸ§ͺ Ideal for reverse access and testing
  • πŸš€ Drop-in replacement, zero config


πŸ•΅πŸΌ Usage

Install it by executing any of the following, depending on your preferred package manager:

pnpm add @igorskyflyer/uarray
yarn add @igorskyflyer/uarray
npm i @igorskyflyer/uarray

ℹ️ Uses the built-in Proxy object, check browser compatibility on the Can I Use website.



πŸ—’οΈ Examples

import { UArray } from '@igorskyflyer/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 '⚽'


πŸ“ Changelog

πŸ“‘ The changelog is available here, CHANGELOG.md.



πŸͺͺ License

Licensed under the MIT license which is available here, MIT license.



πŸ’– Support

I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. β˜•

Donate to igorskyflyer

Thank you for supporting my efforts! πŸ™πŸ˜Š


🧬 Related

@igorskyflyer/str-is-in

🧡 Provides ways of checking whether a String is present in an Array of Strings using custom Comparators. πŸ”


@igorskyflyer/keppo

🎑 Parse, manage, compare and output SemVer-compatible version numbers. πŸ›‘


@igorskyflyer/chars-in-string

πŸͺ Provides ways of testing whether an array of chars is present inside a given String. β˜„


@igorskyflyer/clone

🧬 A lightweight JavaScript utility allowing deep copy-by-value of nested objects, arrays and arrays of objects. πŸͺ


@igorskyflyer/common-color

🎨 Provides common Color-related TypeScript types. 🌈




πŸ‘¨πŸ»β€πŸ’» Author

Created by Igor Dimitrijević (@igorskyflyer).

About

πŸŽ‰ Provides UArray, an Array type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray() and you are all set! πŸ™Œ

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project