1.0.0 • Published 8 years ago
vql v1.0.0
vql.js
a very quick javascript library for doing very quick stuff…
vql is a small auxiliary library and a snappy, more performant replacement for many of javascript's slow native functions.
Install
$ npm install vql
Usage
var vql = require('vql');
API
vql.forEach
vql.forEach(array, callback, thisArg);
Iterates over an array, invoking callback for each element
Parameters
array
(Array): The array to iterate overcallback
(Function): The callback to invoke on each item. You can return false in the callback to break the loop.value
(Any): The value of the current elementindex
(Number): The current indexarray
(Array): A reference to the array currently being iteratedthisArg
(Object): The context
vql.forEach([1, 2, 3, 4], function (value) {
console.log(value);
});
// will console log 1, 2, 3, 4
vql.concat
vql.concat(firstList, secondList);
Concatenates two lists into a single one
Parameters
firstList
(Array): The first arraysecondList
(Array): The second array
Returns
(Array): The concatenation of the two lists
vql.concat([1, 2, 3], [4, 5, 6]);
// => [1, 2, 3, 4, 5, 6]
vql.indexOf
vql.indexOf(array, value);
Return the first index of the element that matches the value. If not match was found return -1
Parameters
array
(Array): The array in which to find the first index of the valuevalue
(Any): The value to find the first index of.
Returns
(Number): The index of the first match OR -1
vql.indexOf(['yes', 'no', 'maybe'], 'maybe');
// => 2
vql.fill
vql.fill(array, value);
Returns a new array with same length but all element are a copy of value.
Parameters
array
(Array): The array to copyvalue
(Any): The value to fill new array with
Returns
(Array): Array filled with value
vql.fill([1, 2, 3], 'waoaw');
// => ['waoaw', 'waoaw', 'waoaw']
1.0.0
8 years ago