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

array-any-index

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-any-index

get values from an array using any index: negative or float

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

array-any-index

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

This module allows you to get values from an array using any index. This means that you can pass in a negative index or a float value. If float values are passed in, then interpolation will be used to calculate the value. If a negative index is passed in, then we travel backwards through the array to get a value. If an index that is larger than the array is passed in, we "loop" back through the array to get the value.

See Getting Started below for usage instructions or d3-interpolate for information on how we calculate float indexes.

Getting Started

Install the module with: npm install array-any-index

var arrayGet = require('array-any-index');
var arr = [0, 1, 2, 3, 4, 5];
arrayGet(arr, 2); // result: 2
arrayGet(arr, 2.5); // result: 2.5
arrayGet(arr, -2); // result: 4
arrayGet(['red', 'blue'], 0.5); // result: '#080080'

See Also

License

Copyright (c) 2015 skratchdot
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 03 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