Skip to content

Commit

Permalink
Merge 5df9c98 into 7e6b4e1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumolari committed Feb 18, 2019
2 parents 7e6b4e1 + 5df9c98 commit dd8b805
Show file tree
Hide file tree
Showing 40 changed files with 2,280 additions and 1,207 deletions.
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": ["@babel/preset-env"]
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
yarn-error.log
node_modules
dist
.DS_Store
coverage
62 changes: 46 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"name": "@geoblink/lodash-mixins",
"version": "1.1.2",
"version": "1.2.0",
"description": "A collection of useful functions built on top of Lodash",
"main": "dist/index.js",
"files": [
"dist"
],
"author": "Geoblink <contact@geoblink.com>",
"scripts": {
"type-check": "tsc --noEmit",
"type-check:watch": "run-s \"type-check --watch\"",
"test": "run-s test:*",
"test:unit": "nyc mocha",
"test:dist": "run-s build && es-check es5 dist/**/*.js",
"test:types": "run-s type-check",
"test:unit": "nyc mocha test/unit/**/*.ts test/integration/**/*.ts",
"test:dist": "run-s build && es-check es5 dist/**/*.js && mocha test/e2e/**/*.ts",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"build": "rm -rf dist && babel src --out-dir dist",
"build": "run-s build:*",
"build:clean": "rm -rf dist",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir dist --extensions '.ts' --source-maps inline",
"docs": "run-s docs:*",
"docs:build": "rm -rf docs && jsdoc --configure .jsdoc.json --verbose && mv docs/@geoblink/lodash-mixins/*/* docs/ && rm -rf docs/@geoblink",
"docs:commit": "if [[ $(git status docs --porcelain) ]]; then git add docs && git commit -m \":memo: Update documentation\"; fi",
Expand All @@ -25,30 +31,54 @@
],
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"@babel/preset-typescript": "^7.1.0",
"@types/chai": "^4.1.7",
"@types/lodash": "^4.14.120",
"@types/mocha": "^5.2.5",
"@types/sinon": "^7.0.5",
"@types/sinon-chai": "^3.2.2",
"chai": "^4.2.0",
"coveralls": "^3.0.2",
"es-check": "^4.0.0",
"eslint": "^5.6.1",
"es-check": "^5.0.0",
"eslint": "^5.13.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"fs-extra": "^7.0.1",
"jsdoc": "^3.5.5",
"jsdoc-template": "https://github.com/braintree/jsdoc-template",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"npm-run-all": "^4.1.3",
"nyc": "^13.0.1",
"sinon": "^6.3.5",
"sinon-chai": "^3.2.0"
"npm-run-all": "^4.1.5",
"nyc": "^13.2.0",
"sinon": "^7.2.3",
"sinon-chai": "^3.3.0",
"source-map-support": "^0.5.10",
"ts-node": "^8.0.2",
"typescript": "^3.3.1"
},
"peerDependencies": {
"lodash": "^4.17.11"
},
"dependencies": {}
"nyc": {
"extension": [
".ts"
],
"exclude": [
"coverage/**/*",
"dist/**/*",
"docs/**/*",
"test/**/*"
],
"reporter": [
"text",
"html"
],
"all": true
}
}
16 changes: 0 additions & 16 deletions src/constants.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Possible results when comparing two items.
*/
enum SORTING_ORDER {
/** Any negative number */
LHS_BEFORE_RHS = -1,
/** Any positive number */
LHS_AFTER_RHS = 1,
/** Zero */
EQUAL = 0
}

export { SORTING_ORDER }
15 changes: 0 additions & 15 deletions src/fromPairsMap.js

This file was deleted.

120 changes: 120 additions & 0 deletions src/fromPairsMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import _ from 'lodash'

export default fromPairsMap

/**
* Applies `fromPairs` to the result of mapping given `iteratee` to given
* collection.
*
* @param collection Collection to iterate over
* @param iteratee Function invoked per iteration
* @returns New object
*/
export function fromPairsMap<T, PropertyName, TResult> (
collection: T[] | null | undefined,
iteratee: _.ArrayIterator<T, [PropertyName, TResult]>
): _.Dictionary<TResult> {
return _.fromPairs(_.map(collection, iteratee))
}

declare module 'lodash' {
interface LoDashStatic {
/**
* Applies `fromPairs` to the result of mapping given `iteratee` to given
* collection.
*
* @param collection Collection to iterate over
* @param iteratee Function invoked per iteration
* @returns New object
*/
fromPairsMap<T, PropertyName, TResult>(
collection: T[] | null | undefined,
iteratee: ArrayIterator<T, [PropertyName, TResult]>
): Dictionary<TResult>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T, TResult>(
collection: List<T> | null | undefined,
iteratee: ListIterator<T, [PropertyName, TResult]>
): Dictionary<TResult>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T>(
collection: List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined
): Dictionary<T>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T extends object, TResult>(
collection: T | null | undefined,
iteratee: ObjectIterator<T, [PropertyName, TResult]>
): Dictionary<TResult>
}

interface LoDashImplicitWrapper<TValue> {
/**
* @see _.fromPairsMap
*/
fromPairsMap<T, TResult>(
this: LoDashImplicitWrapper<T[] | null | undefined>,
iteratee: ArrayIterator<T, [PropertyName, TResult]>
): LoDashImplicitWrapper<Dictionary<TResult>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T, TResult>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
iteratee: ListIterator<T, [PropertyName, TResult]>
): LoDashImplicitWrapper<Dictionary<TResult>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T>(this: LoDashImplicitWrapper<List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined>): LoDashImplicitWrapper<Dictionary<T>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T extends object, TResult>(
this: LoDashImplicitWrapper<T | null | undefined>,
iteratee: ObjectIterator<T, [PropertyName, TResult]>
): LoDashImplicitWrapper<Dictionary<TResult>>
}

interface LoDashExplicitWrapper<TValue> {
/**
* @see _.fromPairsMap
*/
fromPairsMap<T, TResult>(
this: LoDashExplicitWrapper<T[] | null | undefined>,
iteratee: ArrayIterator<T, [PropertyName, TResult]>
): LoDashExplicitWrapper<Dictionary<TResult>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T, TResult>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
iteratee: ListIterator<T, [PropertyName, TResult]>
): LoDashExplicitWrapper<Dictionary<TResult>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T>(this: LoDashExplicitWrapper<List<T> | Dictionary<T> | NumericDictionary<T> | null | undefined>): LoDashExplicitWrapper<Dictionary<T>>

/**
* @see _.fromPairsMap
*/
fromPairsMap<T extends object, TResult>(
this: LoDashExplicitWrapper<T | null | undefined>,
iteratee: ObjectIterator<T, [PropertyName, TResult]>
): LoDashExplicitWrapper<Dictionary<TResult>>
}
}
15 changes: 0 additions & 15 deletions src/fromPairsMapNonNil.js

This file was deleted.

0 comments on commit dd8b805

Please sign in to comment.