Skip to content

Commit

Permalink
Merge 7910eb8 into d64044a
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumolari committed Apr 30, 2019
2 parents d64044a + 7910eb8 commit 564cb07
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 41 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# v1.2.1

Fixed:

- Fix `mergeForEach` documentation
- Export proper TypeScript definitions

# v1.2.0

Ported to Typescript.

# v1.1.2

Fixes:

- Fix mapNonNil require path in fromPairsMapNonNil file
- Fix `mapNonNil` require path in `fromPairsMapNonNil` file

# v1.1.1

Expand Down
2 changes: 1 addition & 1 deletion docs/fromPairsMap.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _ from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'

export default fromPairsMap

Expand Down
4 changes: 2 additions & 2 deletions docs/fromPairsMapNonNil.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _, { ObjectIterator } from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'

import mapNonNil from './mapNonNil'

Expand All @@ -108,7 +108,7 @@ <h1 class="page-title">
TResult
> (
collection: Collection,
iteratee: ObjectIterator&lt;CollectionItem, [PropertyName, TResult] | null | undefined>
iteratee: _.ObjectIterator&lt;CollectionItem, [PropertyName, TResult] | null | undefined>
) {
return _.fromPairs(mapNonNil(collection, iteratee) as any) // Cast to any since this typecheck is user's responsibility
}
Expand Down
2 changes: 1 addition & 1 deletion docs/getTruthyKeys.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _ from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'

export default getTruthyKeys

Expand Down
11 changes: 11 additions & 0 deletions docs/index.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ <h1 class="page-title">

return _
}

export {
fromPairsMap,
fromPairsMapNonNil,
getTruthyKeys,
hasTruthyValues,
mapNonNil,
mergeForEach,
mGet,
shortcuttedReduce
}
</code></pre>
</article>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/mGet.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _ from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'

export default mGet

Expand Down
6 changes: 3 additions & 3 deletions docs/mapNonNil.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _, { ObjectIterator, Dictionary } from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'

export default mapNonNil

Expand All @@ -102,12 +102,12 @@ <h1 class="page-title">
CollectionItem extends any,
Collection extends (
ArrayLike&lt;CollectionItem | null | undefined> |
Dictionary&lt;CollectionItem | null | undefined>
_.Dictionary&lt;CollectionItem | null | undefined>
),
ResultValue
> (
collection: Collection,
iteratee: ObjectIterator&lt;CollectionItem, ResultValue | null | undefined>
iteratee: _.ObjectIterator&lt;CollectionItem, ResultValue | null | undefined>
) {
return _.filter(_.map(collection, iteratee), isNotNil)

Expand Down
16 changes: 8 additions & 8 deletions docs/mergeForEach.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _ from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'
import { SORTING_ORDER } from './constants'
import { ValueOf } from './types'

Expand Down Expand Up @@ -255,13 +255,13 @@ <h1 class="page-title">
* @param options.rightCallback Callback called when there are elements in
* the right-hand-side collection which cannot be matched with any element
* of the left-hand-side collection.
* @param comparator Function used to compare an item of `lhs` collection
* against an item of `rhs` collection. Negative values mean that `lhs` item
* is **before** `rhs` item, positive values that `lhs` item is **after**
* `rhs` item and `0` that both items are equivalent in terms of sorting.
* Default implementation is equivalent to `&lt;` operator. Will receive as 3rd
* and 4th parameters the iteratees used to get sorting value for `lhs` and
* `rhs`.
* @param options.comparator Function used to compare an item of `lhs`
* collection against an item of `rhs` collection. Negative values mean that
* `lhs` item is **before** `rhs` item, positive values that `lhs` item is
* **after** `rhs` item and `0` that both items are equivalent in terms of
* sorting. Default implementation is equivalent to `&lt;` operator. Will
* receive as 3rd and 4th parameters the iteratees used to get sorting value
* for `lhs` and `rhs`.
*/
mergeForEach&lt;
L extends any,
Expand Down
2 changes: 1 addition & 1 deletion docs/shortcuttedReduce.ts.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="page-title">

<section>
<article>
<pre class="prettyprint source linenums"><code>import _ from 'lodash'
<pre class="prettyprint source linenums"><code>import * as _ from 'lodash'
import { ValueOf } from './types'

export default shortcuttedReduce
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@geoblink/lodash-mixins",
"version": "1.2.0",
"version": "1.2.1-beta.2",
"description": "A collection of useful functions built on top of Lodash",
"main": "dist/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/fromPairsMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'

export default fromPairsMap

Expand Down
4 changes: 2 additions & 2 deletions src/fromPairsMapNonNil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _, { ObjectIterator } from 'lodash'
import * as _ from 'lodash'

import mapNonNil from './mapNonNil'

Expand All @@ -19,7 +19,7 @@ export function fromPairsMapNonNil <
TResult
> (
collection: Collection,
iteratee: ObjectIterator<CollectionItem, [PropertyName, TResult] | null | undefined>
iteratee: _.ObjectIterator<CollectionItem, [PropertyName, TResult] | null | undefined>
) {
return _.fromPairs(mapNonNil(collection, iteratee) as any) // Cast to any since this typecheck is user's responsibility
}
Expand Down
2 changes: 1 addition & 1 deletion src/getTruthyKeys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'

export default getTruthyKeys

Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ export default function (_: LoDashStatic) {

return _
}

export {
fromPairsMap,
fromPairsMapNonNil,
getTruthyKeys,
hasTruthyValues,
mapNonNil,
mergeForEach,
mGet,
shortcuttedReduce
}
2 changes: 1 addition & 1 deletion src/mGet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'

export default mGet

Expand Down
6 changes: 3 additions & 3 deletions src/mapNonNil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _, { ObjectIterator, Dictionary } from 'lodash'
import * as _ from 'lodash'

export default mapNonNil

Expand All @@ -13,12 +13,12 @@ function mapNonNil<
CollectionItem extends any,
Collection extends (
ArrayLike<CollectionItem | null | undefined> |
Dictionary<CollectionItem | null | undefined>
_.Dictionary<CollectionItem | null | undefined>
),
ResultValue
> (
collection: Collection,
iteratee: ObjectIterator<CollectionItem, ResultValue | null | undefined>
iteratee: _.ObjectIterator<CollectionItem, ResultValue | null | undefined>
) {
return _.filter(_.map(collection, iteratee), isNotNil)

Expand Down
16 changes: 8 additions & 8 deletions src/mergeForEach.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'
import { SORTING_ORDER } from './constants'
import { ValueOf } from './types'

Expand Down Expand Up @@ -166,13 +166,13 @@ declare module 'lodash' {
* @param options.rightCallback Callback called when there are elements in
* the right-hand-side collection which cannot be matched with any element
* of the left-hand-side collection.
* @param comparator Function used to compare an item of `lhs` collection
* against an item of `rhs` collection. Negative values mean that `lhs` item
* is **before** `rhs` item, positive values that `lhs` item is **after**
* `rhs` item and `0` that both items are equivalent in terms of sorting.
* Default implementation is equivalent to `<` operator. Will receive as 3rd
* and 4th parameters the iteratees used to get sorting value for `lhs` and
* `rhs`.
* @param options.comparator Function used to compare an item of `lhs`
* collection against an item of `rhs` collection. Negative values mean that
* `lhs` item is **before** `rhs` item, positive values that `lhs` item is
* **after** `rhs` item and `0` that both items are equivalent in terms of
* sorting. Default implementation is equivalent to `<` operator. Will
* receive as 3rd and 4th parameters the iteratees used to get sorting value
* for `lhs` and `rhs`.
*/
mergeForEach<
L extends any,
Expand Down
2 changes: 1 addition & 1 deletion src/shortcuttedReduce.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'
import { ValueOf } from './types'

export default shortcuttedReduce
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash'
import * as _ from 'lodash'
import lodashMixins from '../..'
import { expect } from 'chai'

Expand All @@ -15,7 +15,7 @@ describe('Exported package', function () {

describe('When loading exported package', function () {
before('Load mixins', function () {
lodashMixins(_)
lodashMixins(_ as unknown as _.LoDashStatic)
})

for (const method of injectedMethods) {
Expand Down
14 changes: 11 additions & 3 deletions test/integration/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import _ from 'lodash'
import lodashMixins from '../../src/index'
import * as _ from 'lodash'
import lodashMixins, * as namedExports from '../../src/index'
import { expect } from 'chai'

import injectedMethods from '../exportedMethods'

describe('Exported package', function () {
describe('Named exports', function () {
for (const method of injectedMethods) {
it(`Should export have named export «${method}»`, function () {
expect(namedExports).to.have.property(method).that.is.a('function')
})
}
})

describe('Before loading mixins', function () {
for (const method of injectedMethods) {
it(`Should not have «${method}» present`, function () {
Expand All @@ -15,7 +23,7 @@ describe('Exported package', function () {

describe('When loading exported package', function () {
before('Load mixins', function () {
lodashMixins(_)
lodashMixins(_ as unknown as _.LoDashStatic)
})

for (const method of injectedMethods) {
Expand Down

0 comments on commit 564cb07

Please sign in to comment.