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

calculate-from-index-x

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 3.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
494
decreased by-56.09%
Maintainers
1
Weekly downloads
 
Created
Source

Travis status Dependency status devDependency status npm version

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

Package last updated on 17 Jul 2019

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