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

move-element

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

move-element

Move an array element to a given position.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

move-element

js-standard-style npm version

Move an array element to a given position.

Install

    npm install --save --save-exact move-element

Usage

    const moveElement = require('move-element')
    // Say you have an array of fruits
    const fruits = ['Oranges', 'Apples', 'Bananas', 'Pineapples']
    // And you want to swap the positions of 'Apples' and 'Bananas'
    // First you make a function that returns true for the element you want to move
    const isApples = (x) => x === 'Apples'
    // Then you call moveElement with the index you want to move the element to
    const newArray = moveElement(fruits, isApple, 2)
    // Then newArray will be set to:
    // ['Oranges', 'Bananas', 'Apples', 'Pineapples']

License

MIT © Thomas Marek

Keywords

FAQs

Package last updated on 25 Feb 2016

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