-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
197 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.nyc_output | ||
yarn-error.log | ||
node_modules | ||
dist | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"source": { | ||
"include": [ | ||
"src", | ||
"package.json", | ||
"README.md" | ||
], | ||
"includePattern": ".js$", | ||
"excludePattern": "(node_modules/|docs)" | ||
}, | ||
"templates": { | ||
"referenceTitle": "Geoblink Lodash Mixins", | ||
"disableSort": true | ||
}, | ||
"opts": { | ||
"template": "./node_modules/jsdoc-template", | ||
"destination": "./docs/", | ||
"encoding": "utf8", | ||
"recurse": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.* | ||
docs | ||
test | ||
src | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
var _ = require('lodash') | ||
|
||
module.exports = fromPairsMap | ||
|
||
/** | ||
* Applies fromPairs to the result of mapping the given iteratee to the given array. | ||
* Applies `fromPairs` to the result of mapping given `iteratee` to given | ||
* collection. | ||
* | ||
* @param {Array|Object} collection The collection to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Object} Returns the new object. | ||
* @param {Array|Object} collection Collection to iterate over | ||
* @param {Function} iteratee Function invoked per iteration | ||
* @returns {Object} New object | ||
*/ | ||
module.exports = function fromPairsMap (collection, iteratee) { | ||
function fromPairsMap (collection, iteratee) { | ||
return _.fromPairs(_.map(collection, iteratee)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
var _ = require('lodash') | ||
|
||
module.exports = getTruthyKeys | ||
|
||
/** | ||
* Gets the truthy values of the collection. | ||
* Gets the keys associated with truthy values in given collection. | ||
* | ||
* @param {Array|Object} collection The collection to iterate over. | ||
* @param {Function} parseKeyFunction The function invoked per iteration. | ||
* @returns {Object} Returns the new filtered collection. | ||
* @param {Array|Object} collection Collection to iterate over. | ||
* @param {Function} parseKeyFunction Function invoked per iteration. This | ||
* function takes as parameter a key of a truthy value. The value it returns | ||
* will be used in resulting list. Note that if this function returns a falsy | ||
* value value, the key won't be present in resulting collection. | ||
* @returns {Array} New list with just the keys of truthy entries, for which | ||
* `parseKeyFunction` returned a truthy value. | ||
*/ | ||
module.exports = function getTruthyKeys (collection, parseKeyFunction) { | ||
function getTruthyKeys (collection, parseKeyFunction) { | ||
var isFunction = _.isFunction(parseKeyFunction) | ||
return _.filter(_.map(collection, function (value, key) { | ||
if (value) { | ||
return isFunction ? parseKeyFunction(key) : key | ||
} | ||
if (!value) return false | ||
return isFunction ? parseKeyFunction(key) : key | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
var shortcuttedReduce = require('./shortcuttedReduce') | ||
|
||
module.exports = hasTruthyValues | ||
|
||
/** | ||
* Returns whether given object has at least one truthy value for one of its keys. | ||
* Returns whether given collection has at least one truthy value for one of its | ||
* keys. | ||
* | ||
* This function stops traversing the collection as soon as it finds a truthy | ||
* value. | ||
* | ||
* @param {Object} object Object to be checked. | ||
* @param {Object|Array} collection Collection to iterate over. | ||
* @returns {Boolean} `true` if there's at least one value which is truthy. | ||
*/ | ||
module.exports = function hasTruthyValues (object) { | ||
return shortcuttedReduce(object, function (accum, value) { | ||
function hasTruthyValues (collection) { | ||
return shortcuttedReduce(collection, function (accum, value) { | ||
return accum || !!value | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
var _ = require('lodash') | ||
|
||
module.exports = mGet | ||
|
||
/** | ||
* Multiple get. | ||
* Returns multiple values of an object, defaulting missing ones to a common | ||
* default. | ||
* | ||
* @param {Object} object The object to query. | ||
* @param {Array} arrayOfKeys Array with the paths of the properties to get. | ||
* @param {*} defaultValue The value returned for undefined resolved values. | ||
* @return {Array} Returns the new mapped array. | ||
* @param {Object} object Object to be queried. | ||
* @param {string[]} arrayOfKeys Array with the paths of the properties to get. | ||
* @param {any} defaultValue The value returned for missing resolved values. | ||
* @return {Array} New array with values for given key paths or default one. | ||
*/ | ||
module.exports = function mGet (object, arrayOfKeys, defaultValue) { | ||
return _.map(arrayOfKeys, function (key) { return _.get(object, key, defaultValue) }) | ||
function mGet (object, arrayOfKeys, defaultValue) { | ||
return _.map(arrayOfKeys, getValueOrDefault) | ||
|
||
function getValueOrDefault (key) { | ||
return _.get(object, key, defaultValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.