
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
es6-array-compose
Advanced tools
Create a proxy joining two arrays in a single one, while still being sepparated arrays
This package adds a new method to the array prototype, allowing to chain arrays in a single virtual array.
require('es6-array-compose');
var arr1 = [1,2];
var arr2 = [5,6];
arr = arr1.compose(arr2);
console.log('(%s) %s', arr.length, arr); // (4) [1,2,5,6]
arr1.push(3);
console.log('(%s) %s', arr.length, arr); // (5) [1,2,3,5,6]
arr2.shift(4);
console.log('(%s) %s', arr.length, arr); // (5) [1,2,3,4,5,6]
ES6 proxies are (and there are good reasons for that) opaque. Which means that no matter what:
var arr = arr1.compose(arr2);
arr !== arr1.concat(arr2); //true
arr != arr1.concat(arr2); //true
As a workaround, you can check equality this way:
arr.equals(arr1.concat(arr2)) //true
arr.equals(arr1.concat(arr2)) //true
Which of course is much slower than the regular equality operation
These are just examples, it doesn't mean that it's a good idea to do things like this, but it will give you some ideas, don't hesitate to share with me any use you may find for this.
var p1 = [f1,f2,f3];
var p2 = [f4,f5,f6];
var p = p1.compose(p2);
p.reduce((prev, cur) => return prev.push(cur()), []);
// This will run all the processes, starting from the p1 priority list, and return an array of all the return values
Please, note that you should not modify the amount of objects from the list, using push, pop, shift, splice or unshift, since there is no way to know on which array will the element end.
var deck = [
'A♥','2♥','3♥','4♥','5♥','6♥','7♥','8♥','9♥','10♥','J♥','Q♥','K♥',
'A♦','2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦',
'A♣','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣',
'A♠','2♠','3♠','4♠','5♠','6♠','7♠','8♠','9♠','10♠','J♠','Q♠','K♠'
];
var p1, p2, p3, p4, board, deck;
// Two cards for each player, and five in the board
p1.push(deck.pop());
p1.push(deck.pop());
p2.push(deck.pop());
p2.push(deck.pop());
p3.push(deck.pop());
p3.push(deck.pop());
p4.push(deck.pop());
p4.push(deck.pop());
board.push(deck.pop());
board.push(deck.pop());
board.push(deck.pop());
board.push(deck.pop());
board.push(deck.pop());
var game = p1.compose(p2).compose(p3).compose(p4).compose(board).compose(deck);
console.log(game);
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex ;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
console.log(game);
FAQs
Create a proxy joining two arrays in a single one, while still being sepparated arrays
The npm package es6-array-compose receives a total of 7 weekly downloads. As such, es6-array-compose popularity was classified as not popular.
We found that es6-array-compose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.