Skip to content

Commit

Permalink
feat: Update packages, fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Dec 28, 2020
1 parent 8cdd4c9 commit 950dc0d
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 78 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"@babel/runtime-corejs3": "^7.12.5"
},
"devDependencies": {
"@asd14/eslint-config": "^5.19.0",
"@asd14/eslint-config": "^5.20.0",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/register": "^7.12.10",
"babel-eslint": "^10.1.0",
"benchmark": "^2.1.4",
Expand All @@ -65,7 +65,7 @@
"eslint-plugin-no-inferred-method-name": "^2.0.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-unicorn": "^24.0.0",
"eslint-plugin-unicorn": "^25.0.0",
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.20",
"markdownlint-cli": "^0.26.0",
Expand Down
3 changes: 2 additions & 1 deletion src/converge/converge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { converge } from "./converge"
import { reduce } from "../reduce/reduce"
import { read } from "../read/read"

const sum = (...params) => reduce((acc, item) => acc + item, 0, params)

test("converge", t => {
const source = [{ a: 1, b: 2 }]
const sum = (...params) => reduce((acc, item) => acc + item, 0, params)

t.equals(
converge(sum, [read([0, "a"], 0), read([0, "b"], 0)])(source),
Expand Down
11 changes: 5 additions & 6 deletions src/curry/curry.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import test from "tape"

import { curry } from "./curry"

test("curry", t => {
const sum = (a, b) => a + b
const sum = (a, b) => a + b

// can curry multiple times and pass multiple parameters on each curry
const sumThree = (a, b, c) => a + b + c

test("curry", t => {
// does nothing if there are enough parameters
t.equal(curry(sum)(2, 3), 5)

Expand All @@ -13,9 +15,6 @@ test("curry", t => {

t.equal(addTwo(3), 5)

// can curry multiple times and pass multiple parameters on each curry
const sumThree = (a, b, c) => a + b + c

const addOne = curry(sumThree)(1)
const addFourA = curry(addOne)(3)
const addFourB = curry(sumThree)(2, 2)
Expand Down
4 changes: 2 additions & 2 deletions src/deep-equal/deep-equal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import test from "tape"

import { isDeepEqual } from "./deep-equal"

const fn = () => {}

test("isDeepEqual", t => {
t.equal(isDeepEqual(1, 1), true, "Primitives: 1 === 1")

t.equal(isDeepEqual(1, "3"), false, 'Primitives: 1 !== "3"')

const fn = () => {}

t.equal(isDeepEqual(fn, fn), true, "Functions: fn === fn")

t.equal(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "tape"

import { escapeHTML } from "./escapeHTML"
import { escapeHTML } from "./escape-html"

test("escapeHTML", t => {
const actual = escapeHTML(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from "tape"

import { escapeRegExp } from "./escapeRegExp"
import { escapeRegExp } from "./escape-reg-exp"

test("escapeRegExp", t => {
const actualT1 = escapeRegExp("lorem. ipsum [dolor] (sit amet)?")
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { reduce } from "./reduce/reduce"
export { converge } from "./converge/converge"
export { forEach } from "./for-each/for-each"
export { pipe } from "./pipe/pipe"
export { pipeP } from "./pipeP/pipeP"
export { pipeP } from "./pipe-p/pipe-p"
export { read as get, read } from "./read/read"
export { write as set, write } from "./write/write"
export { same } from "./same/same"
Expand Down Expand Up @@ -99,5 +99,5 @@ export { toUpper } from "./to-upper/to-upper"
export { trim } from "./trim/trim"
export { contains } from "./contains/contains"
export { join } from "./join/join"
export { escapeHTML } from "./escapeHTML/escapeHTML"
export { escapeRegExp } from "./escapeRegExp/escapeRegExp"
export { escapeHTML } from "./escape-html/escape-html"
export { escapeRegExp } from "./escape-reg-exp/escape-reg-exp"
7 changes: 3 additions & 4 deletions src/map-matrix/map-matrix.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import test from "tape"

import { mapMatrix } from "./map-matrix"

test("mapMatrix", t => {
const square = value => value * value
const square = x => x * x
const inc = x => x + 1

test("mapMatrix", t => {
t.deepEqual(
mapMatrix(square)([
[1, 2],
Expand All @@ -29,8 +30,6 @@ test("mapMatrix", t => {
"Uncurried (square, [[1, 2], [3, 4]]) // => [[1, 4], [9, 16]]"
)

const inc = x => x + 1

t.deepEqual(
mapMatrix(
[square, inc],
Expand Down
4 changes: 2 additions & 2 deletions src/map/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import test from "tape"

import { map } from "./map"

test("map", t => {
const square = value => value * value
const square = value => value * value

test("map", t => {
t.deepEqual(
map(square, [1, 2, 3]),
[1, 4, 9],
Expand Down
15 changes: 7 additions & 8 deletions src/max/max.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ test("max", t => {
t.end()
})

const toDate = element => new Date(element.time)

test("maxBy", t => {
t.equals(maxBy(i, [1, 10, 3]), 10, "Find max in all positive numeric array")

Expand All @@ -21,15 +23,12 @@ test("maxBy", t => {
"Find max in empty array using transform function (=> undefined)"
)

const fn = element => new Date(element.time)
const source = [
{ time: "2018-05-15T11:20:07.754110Z" },
{ time: "2018-06-11T09:01:54.337344Z" },
{ time: "2018-06-08T08:26:12.711071Z" },
]

t.deepEquals(
maxBy(fn, source),
maxBy(toDate, [
{ time: "2018-05-15T11:20:07.754110Z" },
{ time: "2018-06-11T09:01:54.337344Z" },
{ time: "2018-06-08T08:26:12.711071Z" },
]),
{ time: "2018-06-11T09:01:54.337344Z" },
"Custom transform function"
)
Expand Down
15 changes: 7 additions & 8 deletions src/min/min.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ test("min", t => {
t.end()
})

const toDate = element => new Date(element.time)

test("minBy", t => {
t.equals(
minBy(i, []),
undefined,
"Find min in empty array using transform function (=> undefined)"
)

const fn = element => new Date(element.time)
const source = [
{ time: "2018-06-11T09:01:54.337344Z" },
{ time: "2018-06-08T08:26:12.711071Z" },
{ time: "2018-05-15T11:20:07.754110Z" },
]

t.deepEquals(
minBy(fn, source),
minBy(toDate, [
{ time: "2018-06-11T09:01:54.337344Z" },
{ time: "2018-06-08T08:26:12.711071Z" },
{ time: "2018-05-15T11:20:07.754110Z" },
]),
{ time: "2018-05-15T11:20:07.754110Z" },
"Custom transform function"
)
Expand Down
6 changes: 2 additions & 4 deletions src/mutate/mutate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import test from "tape"

import { mutate, mutateMany, mutateWith } from "./mutate"

const inc = x => x + 1

test("mutate", t => {
t.deepEqual(
mutate({ test: "changed" }, { test: "Lorem Ipsum" }),
{ test: "changed" },
"Mutating existing property should return changed object"
)

const inc = x => x + 1

t.deepEqual(
mutate({ test: inc })({ test: 2 }),
{ test: 3 },
Expand Down Expand Up @@ -70,8 +70,6 @@ test("mutateMany", t => {
})

test("mutateWith", t => {
const inc = x => x + 1

t.deepEqual(
mutateWith({ id: 2 }, { count: [inc], other: 2 }, [
{ id: 1 },
Expand Down
4 changes: 2 additions & 2 deletions src/partition/partition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { is } from "../is/is"
import { read } from "../read/read"
import { partition, partitionWith } from "./partition"

test("partition", t => {
const equalsTwo = x => x === 2
const equalsTwo = x => x === 2

test("partition", t => {
t.deepEqual(
partition(equalsTwo)([2, 2, 1, 1, 2]),
[
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/pipeP/pipeP.test.js → src/pipe-p/pipe-p.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import test from "tape"
import { pipeP } from ".."
import { pipeP } from "./pipe-p"

test("pipeP", t => {
const inc = input => input + 1
const sum = (a = 0, b = 0) =>
new Promise(resolve => {
setTimeout(() => {
resolve(a + b)
}, 100)
})
const inc = input => input + 1
const sum = (a = 0, b = 0) =>
new Promise(resolve => {
setTimeout(() => {
resolve(a + b)
}, 100)
})

test("pipeP", t => {
return Promise.all([pipeP(sum, inc)(2), pipeP(sum, inc, inc)(2, 2)]).then(
([first, second]) => {
t.equal(first, 3, "first input arity 1")
Expand Down
14 changes: 3 additions & 11 deletions src/pipe/pipe.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import test from "tape"
import { pipe } from ".."

/**
* Performs left-to-right function composition. The leftmost function may have
* any arity, the remaining functions must be unary.
*
* @example
* pipe( inc, inc )( 2 )
* // => 4
*/
test("core::pipe", t => {
const inc = input => input + 1
const sum = (a, b) => a + b
const inc = input => input + 1
const sum = (a, b) => a + b

test("pipe", t => {
t.deepEqual(pipe(inc, inc)(2), 4, "first input arity 1")

t.deepEqual(pipe(sum, inc)(2, 2), 5, "first input arity 2")
Expand Down
4 changes: 2 additions & 2 deletions src/repeat/repeat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import test from "tape"

import { repeat } from "./repeat"

test("repeat", t => {
const inc = x => x + 1
const inc = x => x + 1

test("repeat", t => {
t.deepEqual(repeat(inc)(5), [1, 2, 3, 4, 5], "Repeat function curried")
t.deepEqual(repeat(inc, 2), [1, 2], "Repeat function uncurried ")
t.deepEqual(repeat([inc, inc], 2), [2, 3], "Repeat with function chain")
Expand Down
2 changes: 1 addition & 1 deletion src/trim/trim.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { escapeRegExp } from "../escapeRegExp/escapeRegExp"
import { escapeRegExp } from "../escape-reg-exp/escape-reg-exp"

const _trim = (char = " ", source) => {
const safeChar = escapeRegExp(char)
Expand Down
6 changes: 2 additions & 4 deletions src/update/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import test from "tape"

import { update, updateMany, updateWith } from "./update"

const inc = x => x + 1

test("update", t => {
t.deepEqual(
update({ test: "changed" }, { test: "Lorem Ipsum" }),
{ test: "changed" },
"Updating existing property should return changed object"
)

const inc = x => x + 1

t.deepEqual(
update({ test: inc })({ test: 2 }),
{ test: 3 },
Expand Down Expand Up @@ -59,8 +59,6 @@ test("updateMany", t => {
})

test("updateWith", t => {
const inc = x => x + 1

t.deepEqual(
updateWith(
{
Expand Down

0 comments on commit 950dc0d

Please sign in to comment.