Skip to content

Commit

Permalink
💡 Update static html docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Pillado committed Feb 8, 2021
1 parent 3594a1e commit 7f78cf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
25 changes: 11 additions & 14 deletions docs/getTruthyKeys.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,22 @@ <h1 class="page-title">
* @param collection Collection to iterate over.
* @param 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 New list with just the keys of truthy entries, for which
* `parseKeyFunction` returned a truthy value.
* will be used in resulting list.
* @returns New list with just the keys of truthy entries.
*/
function getTruthyKeys&lt;T extends object, TResult>(
collection: T | null | undefined,
parseKeyFunction?: (key: string) => TResult
): (string | TResult)[] {
const isFunction = _.isFunction(parseKeyFunction)

const mappedCollection = _.map(collection, function (value, key) {
if (!value) return false
return parseKeyFunction &amp;&amp; isFunction ? parseKeyFunction(key) : key
})

return _.filter(mappedCollection) as (string | TResult)[] // Casting needed to remove `false`
return _.reduce(collection, function (acc: (string | TResult)[], value, key) {
if (value) {
const parsedKey = parseKeyFunction &amp;&amp; isFunction ? parseKeyFunction(key) : key
acc.push(parsedKey)
}
return acc
}, [])
}

declare module 'lodash' {
Expand All @@ -124,10 +123,8 @@ <h1 class="page-title">
* @param collection Collection to iterate over.
* @param 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 New list with just the keys of truthy entries, for which
* `parseKeyFunction` returned a truthy value.
* will be used in resulting list.
* @returns New list with just the keys of truthy entries.
*/
getTruthyKeys&lt;T extends object, TResult>(
collection: T | null | undefined,
Expand Down
5 changes: 2 additions & 3 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,7 @@ <h5>Parameters:</h5>
<td class="description last">
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.
will be used in resulting list.

</td>
</tr>
Expand Down Expand Up @@ -678,7 +677,7 @@ <h5>Parameters:</h5>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="getTruthyKeys.ts.html">getTruthyKeys.ts</a>, <a href="getTruthyKeys.ts.html#line32">line 32</a>
<a href="getTruthyKeys.ts.html">getTruthyKeys.ts</a>, <a href="getTruthyKeys.ts.html#line31">line 31</a>
</li>
</ul>
</dd>
Expand Down

0 comments on commit 7f78cf5

Please sign in to comment.