Skip to content

Commit 6797f89

Browse files
committed
Updated dependencies and reran lint
1 parent bffca0e commit 6797f89

File tree

4 files changed

+919
-683
lines changed

4 files changed

+919
-683
lines changed

.eslintrc.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
2-
extends: "standard"
3-
plugins: [markdown]
4-
rules:
5-
no-unused-vars: 0
6-
eqeqeq: 0
7-
no-undef: 0
8-
no-extend-native: 0
2+
extends:
3+
- "standard"
4+
- "plugin:markdown/recommended"
5+
plugins: [markdown]
6+
rules:
7+
no-unused-vars: 0
8+
eqeqeq: 0
9+
no-undef: 0
10+
no-extend-native: 0

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
},
1919
"homepage": "https://github.com/hemanth/functional-programming-jargon#readme",
2020
"devDependencies": {
21-
"eslint": "^6.6.0",
22-
"eslint-config-standard": "^6.0.0",
23-
"eslint-plugin-markdown": "^1.0.0-beta.6",
24-
"eslint-plugin-promise": "^4.2.1",
25-
"eslint-plugin-standard": "^3.0.1",
21+
"eslint": "^8.20.0",
22+
"eslint-config-standard": "^17.0.0",
23+
"eslint-plugin-import": "^2.26.0",
24+
"eslint-plugin-markdown": "^3.0.0",
25+
"eslint-plugin-n": "^15.2.4",
26+
"eslint-plugin-promise": "^6.0.0",
27+
"eslint-plugin-standard": "^5.0.0",
2628
"pre-commit": "^1.2.2",
2729
"roadmarks": "^1.6.3"
2830
},

readme.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ __Table of Contents__
7575
* [Option](#option)
7676
* [Function](#function)
7777
* [Partial function](#partial-function)
78+
* [Dealing with partial functions](#dealing-with-partial-functions)
7879
* [Functional Programming Libraries in JavaScript](#functional-programming-libraries-in-javascript)
7980

8081

@@ -121,7 +122,7 @@ This allows the values in the closure to be accessed by returned functions.
121122

122123
```js
123124
const addTo = x => y => x + y
124-
var addToFive = addTo(5)
125+
const addToFive = addTo(5)
125126
addToFive(3) // => 8
126127
```
127128

@@ -179,7 +180,6 @@ curriedSum(40)(2) // 42.
179180
const add2 = curriedSum(2) // (b) => 2 + b
180181

181182
add2(10) // 12
182-
183183
```
184184

185185
## Auto Currying
@@ -372,12 +372,15 @@ class Max {
372372
constructor (a) {
373373
this.a = a
374374
}
375+
375376
id () {
376377
return this
377378
}
379+
378380
compose (b) {
379381
return this.a > b.a ? this : b
380382
}
383+
381384
toString () {
382385
return `Max(${this.a})`
383386
}
@@ -396,7 +399,7 @@ Anything that can be assigned to a variable.
396399

397400
```js
398401
5
399-
Object.freeze({name: 'John', age: 30}) // The `freeze` function enforces immutability.
402+
Object.freeze({ name: 'John', age: 30 }) // The `freeze` function enforces immutability.
400403
;(a) => a
401404
;[1]
402405
undefined
@@ -408,15 +411,15 @@ A variable that cannot be reassigned once defined.
408411

409412
```js
410413
const five = 5
411-
const john = Object.freeze({name: 'John', age: 30})
414+
const john = Object.freeze({ name: 'John', age: 30 })
412415
```
413416

414417
Constants are [referentially transparent](#referential-transparency). That is, they can be replaced with the values that they represent without affecting the result.
415418

416419
With the above two constants the following expression will always return `true`.
417420

418421
```js
419-
john.age + five === ({name: 'John', age: 30}).age + (5)
422+
john.age + five === ({ name: 'John', age: 30 }).age + 5
420423
```
421424

422425
### Constant Function
@@ -434,15 +437,15 @@ const constant = a => () => a
434437
Object whose `map` doesn't transform the contents. See [Functor](#functor)
435438

436439
```js
437-
Constant(1).map(n => n + 1) // => Constant(1)
440+
Constant(1).map(n => n + 1) // => Constant(1)
438441
```
439442

440443
### Constant Monad
441444

442445
Object whose `chain` doesn't transform the contents. See [Monad](#monad)
443446

444447
```js
445-
Constant(1).chain(n => Constant(n + 1)) // => Constant(1)
448+
Constant(1).chain(n => Constant(n + 1)) // => Constant(1)
446449
```
447450

448451
## Functor
@@ -581,7 +584,7 @@ A branch of mathematics that uses functions to create a [universal model of comp
581584
Lazy evaluation is a call-by-need evaluation mechanism that delays the evaluation of an expression until its value is needed. In functional languages, this allows for structures like infinite lists, which would not normally be available in an imperative language where the sequencing of commands is significant.
582585

583586
```js
584-
const rand = function*() {
587+
const rand = function * () {
585588
while (1 < 2) {
586589
yield Math.random()
587590
}
@@ -742,13 +745,13 @@ For example, 2D coordinates could be stored as an array `[2,3]` or object `{x: 2
742745

743746
```js
744747
// Providing functions to convert in both directions makes them isomorphic.
745-
const pairToCoords = (pair) => ({x: pair[0], y: pair[1]})
748+
const pairToCoords = (pair) => ({ x: pair[0], y: pair[1] })
746749

747750
const coordsToPair = (coords) => [coords.x, coords.y]
748751

749752
coordsToPair(pairToCoords([1, 2])) // [1, 2]
750753

751-
pairToCoords(coordsToPair({x: 1, y: 2})) // {x: 1, y: 2}
754+
pairToCoords(coordsToPair({ x: 1, y: 2 })) // {x: 1, y: 2}
752755
```
753756

754757
### Homomorphism
@@ -881,14 +884,14 @@ const nameLens = R.lens(
881884
// getter for name property on an object
882885
(obj) => obj.name,
883886
// setter for name property
884-
(val, obj) => Object.assign({}, obj, {name: val})
887+
(val, obj) => Object.assign({}, obj, { name: val })
885888
)
886889
```
887890

888891
Having the pair of get and set for a given data structure enables a few key features.
889892

890893
```js
891-
const person = {name: 'Gertrude Blanch'}
894+
const person = { name: 'Gertrude Blanch' }
892895

893896
// invoke the getter
894897
R.view(nameLens, person) // 'Gertrude Blanch'
@@ -911,7 +914,7 @@ const firstLens = R.lens(
911914
(val, [__, ...xs]) => [val, ...xs]
912915
)
913916

914-
const people = [{name: 'Gertrude Blanch'}, {name: 'Shafi Goldwasser'}]
917+
const people = [{ name: 'Gertrude Blanch' }, { name: 'Shafi Goldwasser' }]
915918

916919
// Despite what you may assume, lenses compose left-to-right.
917920
R.over(compose(firstLens, nameLens), uppercase, people) // [{'name': 'GERTRUDE BLANCH'}, {'name': 'Shafi Goldwasser'}]
@@ -1033,8 +1036,8 @@ const getPrice = (item) => maybeProp('price', item)
10331036
const getNestedPrice = (cart) => getItem(cart).chain(getPrice)
10341037

10351038
getNestedPrice({}) // None()
1036-
getNestedPrice({item: {foo: 1}}) // None()
1037-
getNestedPrice({item: {price: 9.99}}) // Some(9.99)
1039+
getNestedPrice({ item: { foo: 1 } }) // None()
1040+
getNestedPrice({ item: { price: 9.99 } }) // Some(9.99)
10381041
```
10391042

10401043
`Option` is also known as `Maybe`. `Some` is sometimes called `Just`. `None` is sometimes called `Nothing`.

0 commit comments

Comments
 (0)