Socket
Socket
Sign inDemoInstall

calculate-from-index-x

Package Overview
Dependencies
45
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    calculate-from-index-x

Calculates a fromIndex of a given value for an array.


Version published
Weekly downloads
501
increased by7.05%
Maintainers
1
Install size
4.64 MB
Created
Weekly downloads
 

Readme

Source

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

calculate-from-index-x

Calculates a fromIndex of a given value for an array.

module.exports(array, fromIndex)number

This method calculates a fromIndex of a given value for an array.

Kind: Exported function
Returns: number - The calculated fromIndex. Default is 0.
Throws:

  • TypeError If array is null or undefined.
ParamTypeDescription
arrayarray* The array on which to calculate the starting index.
fromIndexnumber* The position in this array at which to begin. A negative value gives the index of array.length + fromIndex by asc.

Example

import calcFromIndex from 'calculate-from-index-x';

console.log(calcFromIndex([1, 2, 3], 1)); // 1
console.log(calcFromIndex([1, 2, 3], Infinity)); // Infinity
console.log(calcFromIndex([1, 2, 3], -Infinity)); // 0
console.log(calcFromIndex([1, 2, 3], -1)); // 2

Keywords

FAQs

Last updated on 28 Aug 2019

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc