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

invert-permutation

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

invert-permutation - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

LICENSE

4

index.js
"use strict"
function invertPermutation(pi) {
var result = new Array(pi.length)
function invertPermutation(pi, result) {
result = result || new Array(pi.length)
for(var i=0; i<pi.length; ++i) {

@@ -6,0 +6,0 @@ result[pi[i]] = i

{
"name": "invert-permutation",
"version": "0.0.0",
"version": "0.1.0",
"description": "Inverts permutations",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,17 +5,28 @@ invert-permutation

Usage
=====
First, install using npm:
Example
========
```javascript
console.log( require("invert-permutation")([1,3,0,2]) )
//Prints:
// [ 2, 1, 3, 0 ]
```
# Install
npm install invert-permutation
Then, you can use it as follows:
console.log( require("invert-permutation")([1,3,0,2]) )
//Prints:
// [ 2, 1, 3, 0 ]
# API
## `require("invert-permutation")(perm[, result])
Inverts a permutation
* `perm` is the permutation to invert
* `result` is an optional array that gets the result of inverting the permutation
**Returns** `result` or a newly allocated array if nothing is specified
Credits
=======
(c) 2013 Mikola Lysenko. MIT License
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