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

faro

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faro - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

54

index.js

@@ -8,6 +8,7 @@ /**

const _weaveArray = a => {
const z = [];
const n2 = Math.ceil(a.length / 2);
const a1 = a.slice(0, n2);
const a2 = a.slice(n2);
const z = [];
let c = 0;

@@ -42,18 +43,2 @@ while (c++ < n2) {

/**
* Perform actual weave
* @param s - Incoming string
* @returns {string} - Result of the weave
* @private
*/
const _weaveString = s => _weaveArray(s.split('')).join('');
/**
* Perform actual unweave
* @param s
* @returns {string}
* @private
*/
const _unweaveString = s => _unweaveArray(s.split('')).join('');
/**
* Perform weave, handling some outlier cases

@@ -66,3 +51,3 @@ * @param s - Incoming string

return _weaveString(s);
return _weaveArray(s.split('')).join('');
};

@@ -78,10 +63,39 @@

return _unweaveString(s);
return _unweaveArray(s.split('')).join('');
};
/**
* Weave array
* @param a
* @returns {*}
*/
const weaveArray = a => {
if (a.length < 3) return a;
return _weaveArray(a);
};
/**
* Unweave array
* @param a
* @returns {*}
*/
const unweaveArray = a => {
if (a.length < 3) return a;
return _unweaveArray(a);
};
module.exports = {
// String based functions
shuffle: weave,
unshuffle: unweave,
weave,
unshuffle: unweave,
unweave,
// Array based functions
shuffleArray: weaveArray,
unshuffleArray: unweaveArray,
weaveArray: weaveArray,
unweaveArray: unweaveArray,
};
{
"name": "faro",
"version": "0.0.2",
"version": "0.1.0",
"description": "Faro out-shuffle a string",

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

const assert = require('assert');
const faro = require('../index');
const { shuffle, weave, unshuffle, unweave } = faro;
const { shuffle, weave, unshuffle, unweave, shuffleArray, weaveArray, unshuffleArray, unweaveArray } = faro;

@@ -100,1 +100,11 @@ describe('Weave', () => {

});
describe('Weave-Array', () => {
describe('Empty array', () => {
it('should return empty array when input is empty array', () => {
assert.equal(weaveArray([]) instanceof Array, true);
assert.equal(weaveArray([]).length, 0);
})
});
});
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