fn-partial
Feel like a memory pointer. Pass a reference to a function.
Javascript is a very dynamic language, but sometimes you need to be more dynamic.
If you need to use something as memory pointers in C isn't possible in JavaScript, but you can do an alternative: a function that calculate the result dynamically.
For example, imagine that you have a collection of players
var players = one: 'Kiko' two: 'Ricard' three: 'Xavi';
and you have a function that return the number of players in the collection:
var { return Objectlength;};
Now, you want to know the numbers of players, and you need to have 4 players for start a new game.
If you do something like this:
var numPlayers = ;console; // => 3playersfour = 'Ben';console; // => 3, expected 4 :(
It's fail because the value is assigned when you call the function.
In languages as C you can create a pointer in the same memory direction and know the value in any time because the pointer referenced the value.
With this package you can simulate something like that.
var partial = var numPlayers = ;console; // => 3playersfour = 'Ben';console; // => 4 YEAH!
More information and the history of this code in StackOverflow
Install
npm install --save object-assign
If you want to use in the browser (powered by Browserify):
Usage
var partial = ; // Call a function without argumentsvar result = ;;// => console.log("Hello World"); // Call a function with argumentsvar result = ;;// => console.log("Hello World, Kiko!, how are you?")
License
MIT © Kiko Beats