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

lodash-permute

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash-permute

Move items in an array (proposed lodash feature #1701)

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
decreased by-67.98%
Maintainers
1
Weekly downloads
 
Created
Source

_.permute lodash mixin

Permute moves items in a Javascript array.

npm install lodash-permute

lodash issue is here. Give it a 👍 if you want to see it added to lodash.

Example

import { permute } from 'lodash-permute'

// permute with an array
permute(['a', 'b', 'c'], [1, 0, 2])
// -> ['b', 'a', 'c']

// permute with a function that returns the desired index for the new array
permute([1, 2, 3, 4, 5], (i, val) => val)
// -> [ , 1, 2, 3, 4, 5]

// you can also do weird stuff like cloning
let names = [{name: 'Fred'}, {name: 'Barney'}, {name: 'Wilma'}, {name: 'Betty'}]
names = permute(names, [1, 1, 1, 2, 2, 2, 3, 3, 3, 0, 0, 0])
// -> [ { name: 'Barney' },
  { name: 'Barney' },
  { name: 'Barney' },
  { name: 'Wilma' },
  { name: 'Wilma' },
  { name: 'Wilma' },
  { name: 'Betty' },
  { name: 'Betty' },
  { name: 'Betty' },
  { name: 'Fred' },
  { name: 'Fred' },
  { name: 'Fred' } ]

FAQs

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