Skip to content

Commit 3a86070

Browse files
committed
feat: Hashable Trait & Hash tables
feat: apply1(), let_in(), call() feat: create(), createFrom(), builder()
1 parent 5fdd418 commit 3a86070

18 files changed

+3382
-60
lines changed

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ module.exports = {
6262
'no-continue': 'off',
6363
'no-plusplus': 'off',
6464

65+
// More elements in one line
66+
'object-curly-newline': ['error', { multiline: true }],
67+
68+
// Functional style
69+
'no-confusing-arrow': 'off',
70+
'implicit-arrow-linebreak': 'off',
71+
6572
// enforce license header (todo: improve plugin to support patterns for multi-lines)
6673
'header/header': [2, 'block', ['',
6774
' * Copyright 2019 Adobe. All rights reserved.',

.jsdoc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"docdash": {
1717
"static": true,
18-
"sort": false,
18+
"sort": true,
1919
"search": true,
2020
"wrap": true,
2121
"typedefs": true

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Features from the Rust language in JavaScript: Provides [Traits](https://doc.rus
1313
- [Table of Contents](#table-of-contents)
1414
- [Status](#status)
1515
- [Usage & Features](#usage--features)
16+
- [Hashing](#hashing)
17+
- [Testing of examples in Documentation](#doctest)
1618
- [Sequence/Iterators](#sequenceiterators)
1719
- [Objects as Sequences](#objects-as-sequences)
1820
- [Reverse Currying](#reverse-currying)
@@ -23,6 +25,10 @@ Features from the Rust language in JavaScript: Provides [Traits](https://doc.rus
2325
- [Typing utilities](#typing-utilities)
2426
- [Functional Utilities](#functional-utilities)
2527
- [Change Log](#change-log)
28+
- [1.8.0](#180)
29+
- [1.7.0](#170)
30+
- [1.6.0](#160)
31+
- [1.5.0](#150)
2632
- [1.4.0](#140)
2733
- [1.3.0](#130)
2834
- [1.2.0](#120)
@@ -47,6 +53,44 @@ Features from the Rust language in JavaScript: Provides [Traits](https://doc.rus
4753
```bash,notest
4854
$ npm add ferrum
4955
```
56+
<a name="hashing"></a>
57+
### Hashing & Hash Tables
58+
59+
Ferrum features an extensible, reliable infrastructure for object hashing
60+
including an implementation of
61+
[HashMap](https://www.ferrumjs.org/module-hashing-HashMap.html) and
62+
[HashSet](https://www.ferrumjs.org/module-hashing-HashSet.html).
63+
64+
It supports [user defined hash functions]() (e.g. blake2 instead of xxhash).
65+
Support for all of the standard types is provided out of the box and
66+
[support for user defined types](https://www.ferrumjs.org/module-hashing-Hashable.html)
67+
or third party types can be provided via the trait infrastructure.
68+
69+
You could even integrate the
70+
[object-hash](https://www.npmjs.com/package/object-hash) package to add support
71+
for hashing arbitrary third party types! See "Sophisticated hasher integrating
72+
object hash" in the
73+
[hasher trait](https://www.ferrumjs.org/module-hashing-Hasher.html) documentation.
74+
75+
```js
76+
const assert = require('assert');
77+
const { HashMap } = require('ferrum');
78+
79+
const m = new Map([[{}, 42], [7, "seven"]]);
80+
assert.strictEqual(m.get(7), "seven");
81+
assert.strictEqual(m.get({}), undefined); // Identity based lookup
82+
83+
const hm = new HashMap([[{}, 42], [7, "seven"]]);
84+
assert.strictEqual(m.get(7), "seven");
85+
assert.strictEqual(m.get({}), 42); // Content based lookup
86+
```
87+
88+
<a name="doctest"></a>
89+
### Testing of Examples
90+
91+
Have you ever found out that some of the examples in your api documentation
92+
or readme contained bugs? You can now use the [Ferrum Doctest](https://github.com/adobe/ferrum.doctest)
93+
companion package to run your examples as part of your regular test harness!
5094

5195
<a name="sequence-iterators"></a>
5296
### Sequence/Iterators
@@ -599,6 +643,27 @@ assertEquals(pair(2)(1), /* => */ [1,2]);
599643
<a name="changelog"></a>
600644
## Change Log
601645

646+
### Features
647+
648+
### 1.8.0
649+
650+
* Move many tests into the documentation examples ([c033897](https://github.com/adobe/ferrum/commit/c033897fc9bc224))
651+
652+
### 1.7.0
653+
654+
* Use ferrum.doctest to make sure examples are valid js code ([b0f9d45](https://github.com/adobe/ferrum/commit/b0f9d45))
655+
656+
657+
### 1.6.0
658+
659+
* Add mutate(), apply() ([8d28f73](https://github.com/adobe/ferrum/commit/d4e3a7a750afe58696097b5f75117c555291d01b))
660+
661+
### 1.5.0
662+
663+
* Alias flatten() -> flat() ([2abad3f](https://github.com/adobe/ferrum/commit/2abad3f4cc72bbad7ee19da8f59d4917))
664+
* group(), multiline() and takeUntil() ([0bc0ca0](https://github.com/adobe/ferrum/commit/0bc0ca0059b6a7f8f61cf))
665+
666+
602667
### 1.4.0
603668

604669
* Add intersperse() ([8d28f73](https://github.com/adobe/ferrum/commit/8d28f73))

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
},
2323
"homepage": "https://github.com/adobe/ferrum#readme",
2424
"dependencies": {
25-
"lodash.isplainobject": "4.0.6"
25+
"lodash.isplainobject": "4.0.6",
26+
"fastestsmallesttextencoderdecoder": "^1.0.22",
27+
"xxhashjs": "^0.2.2"
2628
},
2729
"devDependencies": {
2830
"@semantic-release/changelog": "5.0.1",
@@ -51,7 +53,8 @@
5153
"mocha-multi-reporters": "1.5.1",
5254
"mocha-parallel-tests": "2.3.0",
5355
"nyc": "15.1.0",
54-
"semantic-release": "17.4.2"
56+
"semantic-release": "17.4.2",
57+
"object-hash": "^2.1.1"
5558
},
5659
"renovate": {
5760
"extends": [

0 commit comments

Comments
 (0)