falcor-router
Version:
A router DataSource constructor for falcor that allows you to model all your cloud data sources as a single JSON resource.
34 lines (29 loc) • 788 B
JavaScript
var isArray = Array.isArray;
/**
* plucks any integers from the path key. Makes no effort
* to convert the key into any specific format.
*/
module.exports = function pluckIntegers(keySet) {
var ints = [];
if (typeof keySet === 'object') {
if (isArray(keySet)) {
keySet.forEach(function(key) {
// Range case
if (typeof key === 'object') {
ints[ints.length] = key;
}
else if (!isNaN(+key)) {
ints[ints.length] = +key;
}
});
}
// Range case
else {
ints[ints.length] = keySet;
}
}
else if (!isNaN(+keySet)) {
ints[ints.length] = +keySet;
}
return ints;
};