Skip to content

Commit 3845355

Browse files
feat: implement curry
1 parent 6983c3f commit 3845355

19 files changed

+70
-374
lines changed

.devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "project-blueprint",
2+
"name": "functionaut",
33
"dockerComposeFile": "./docker-compose.yml",
44
"service": "dev",
55
"runServices": ["slate"],

.env

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
# The namespace for your library in a browser.
2-
#
3-
# If you have a library `foo` that you require in Node.js as follow:
4-
#
5-
# const {bar} = require('foo');
6-
# bar();
7-
#
8-
# You can make it available in the browser under a namespace of your choice
9-
# (i.e. it doesn't need to be the same as your Node.js module identifier).
10-
#
11-
# BROWSER_NS=foo
12-
#
13-
# const {bar} = window.foo;
14-
# bar();
15-
#
16-
# BROWSER_NS=MYLIB
17-
#
18-
# const {bar} = window.MYLIB
19-
#
20-
# Behind the scene the Google Closure Compiler will "browserify"
21-
# the exports of your Node.js library as defined in the `dist/index.js` file.
22-
#
23-
BROWSER_NS=PB
24-
25-
# Your package identifier.
26-
PACKAGE_ID=@customcommander/project-blueprint
27-
28-
# This title will be used when publishing documentation on gh-pages
29-
DOC_TITLE=Project Blueprint Fake API
1+
BROWSER_NS=F
2+
PACKAGE_ID=@customcommander/functionaut
3+
DOC_TITLE=Flight Manual

CHANGELOG.md

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +0,0 @@
1-
## [1.8.1](https://github.com/customcommander/project-blueprint/compare/v1.8.0...v1.8.1) (2021-02-13)
2-
3-
4-
### Bug Fixes
5-
6-
* fix bug where table of contents was not properly sorted ([16b72e3](https://github.com/customcommander/project-blueprint/commit/16b72e3b9ce9cc6984c0e54977acaafb662bca7b))
7-
8-
# [1.8.0](https://github.com/customcommander/project-blueprint/compare/v1.7.0...v1.8.0) (2021-02-13)
9-
10-
11-
### Bug Fixes
12-
13-
* fix typo in readme ([12c3c88](https://github.com/customcommander/project-blueprint/commit/12c3c88bc7ab3cd6946aaaf91bd8e3fbdb9843ed))
14-
* remove public access flag when parsing jsdoc annotations and document corresponding makefile target ([810b6e1](https://github.com/customcommander/project-blueprint/commit/810b6e1924e862b4ed08c67a7edcf7f552c34905))
15-
16-
17-
### Features
18-
19-
* add import snippets in docs ([d027fd5](https://github.com/customcommander/project-blueprint/commit/d027fd56fb4949121ad20580a8f92710ecd6c2f2))
20-
* add support for [@throws](https://github.com/throws) jsdoc tag in documentation ([83ddb8d](https://github.com/customcommander/project-blueprint/commit/83ddb8d71a658685b72d9b798bde1f35bd18f90c))
21-
* allow custom intro for docs. closes [#10](https://github.com/customcommander/project-blueprint/issues/10) ([98421a2](https://github.com/customcommander/project-blueprint/commit/98421a22a5089df3bd18136b1f3fbc14fbc879cf))
22-
* allow custom logo for docs ([e8cba61](https://github.com/customcommander/project-blueprint/commit/e8cba61d8960639573f6fa3a9665419c929b3d26))
23-
* does not package code that has no description ([64b1770](https://github.com/customcommander/project-blueprint/commit/64b1770c29cd365be3f93ecabbbc3519e675d4d0))
24-
25-
# [1.7.0](https://github.com/customcommander/project-blueprint/compare/v1.6.0...v1.7.0) (2021-02-07)
26-
27-
28-
### Bug Fixes
29-
30-
* fix bold rendering in deprecation warning ([d5cff67](https://github.com/customcommander/project-blueprint/commit/d5cff67e00d91a25f0db4a07f41a4f00c621469f))
31-
* fix bug where parameters table was reduced to only one row ([bc2e939](https://github.com/customcommander/project-blueprint/commit/bc2e939ae39cb74057bed0cf36359f81ec7748bc))
32-
33-
34-
### Features
35-
36-
* add param description and indicate when a param is optional ([04822a2](https://github.com/customcommander/project-blueprint/commit/04822a2a1acb7aeee6fd01afb35859f772d6cf98))
37-
38-
# [1.6.0](https://github.com/customcommander/project-blueprint/compare/v1.5.0...v1.6.0) (2021-02-07)
39-
40-
41-
### Features
42-
43-
* implement curry to experiment with the closure compiler ([7b11812](https://github.com/customcommander/project-blueprint/commit/7b118122d857f7be81c7f955a0fb1d0eb0bff832))
44-
45-
# [1.5.0](https://github.com/customcommander/project-blueprint/compare/v1.4.2...v1.5.0) (2021-02-06)
46-
47-
48-
### Features
49-
50-
* add support for deprecation ([d7c1e19](https://github.com/customcommander/project-blueprint/commit/d7c1e19e2e5eb7123336b8119f507fb1c906a6bd))
51-
* add support for description, parameters and return value ([47a642c](https://github.com/customcommander/project-blueprint/commit/47a642c38e5510e90a9cb345a8c9eed5a2a7dc5a))
52-
53-
## [1.4.2](https://github.com/customcommander/project-blueprint/compare/v1.4.1...v1.4.2) (2021-02-06)
54-
55-
56-
### Bug Fixes
57-
58-
* deindent run command when building doc ([5693b06](https://github.com/customcommander/project-blueprint/commit/5693b06eb6b78be7a93b4444e656e64810bdebb7))
59-
60-
## [1.4.1](https://github.com/customcommander/project-blueprint/compare/v1.4.0...v1.4.1) (2021-02-06)
61-
62-
63-
### Bug Fixes
64-
65-
* fix setup step on docs deployment ([7d8eff8](https://github.com/customcommander/project-blueprint/commit/7d8eff8d8d7c8dd9395234f4cd8ed2586e568a22))
66-
67-
# [1.4.0](https://github.com/customcommander/project-blueprint/compare/v1.3.0...v1.4.0) (2021-02-06)
68-
69-
70-
### Features
71-
72-
* autogenerate docs using slate. basic support ([7794c98](https://github.com/customcommander/project-blueprint/commit/7794c9868ac4ea5ec51d2a50d3fbee684acbf361))
73-
74-
# [1.3.0](https://github.com/customcommander/project-blueprint/compare/v1.2.0...v1.3.0) (2021-02-05)
75-
76-
77-
### Bug Fixes
78-
79-
* minify node distribution files ([cce2fa4](https://github.com/customcommander/project-blueprint/commit/cce2fa42cd1d4d0cdbedbfeaffcda7225efc622a))
80-
* specify es2019 as input language when transpiling for browser ([224b183](https://github.com/customcommander/project-blueprint/commit/224b183f94758adbdf4083824d6ab067e4da32b7))
81-
82-
83-
### Features
84-
85-
* add basic testing support ([821fffe](https://github.com/customcommander/project-blueprint/commit/821fffee40d14a5e7afeeb2a4d1b65c1a2f9b690))
86-
87-
# [1.2.0](https://github.com/customcommander/project-blueprint/compare/v1.1.0...v1.2.0) (2021-02-04)
88-
89-
90-
### Bug Fixes
91-
92-
* pass secrets as env vars not as key=val pairs ([350eb76](https://github.com/customcommander/project-blueprint/commit/350eb769afc03fb97fda6c3ecebfbd3c8f7143dd))
93-
94-
95-
### Features
96-
97-
* add new github workflow on pull requests ([473d0a9](https://github.com/customcommander/project-blueprint/commit/473d0a93f2e3f920e1ae70fb8f956eebf40889b3))
98-
* use google closure compiler to produce a browser bundle ([ea36c05](https://github.com/customcommander/project-blueprint/commit/ea36c056eca56719ff484b432e633ba2f9f42452))
99-
100-
# [1.1.0](https://github.com/customcommander/project-blueprint/compare/v1.0.2...v1.1.0) (2021-02-01)
101-
102-
103-
### Bug Fixes
104-
105-
* make sure vscode uses bash when working inside a container ([f32c728](https://github.com/customcommander/project-blueprint/commit/f32c728d8eb50062effac84e639d6d3ce20f4719))
106-
107-
108-
### Features
109-
110-
* export symbols based on jsdoc annotations ([79af28f](https://github.com/customcommander/project-blueprint/commit/79af28f585bf923d479bf000f866ba8af9fe8cd6))
111-
112-
## [1.0.2](https://github.com/customcommander/project-blueprint/compare/v1.0.1...v1.0.2) (2021-01-28)
113-
114-
115-
### Bug Fixes
116-
117-
* set public access in package.json to fix 402 npm error ([c18ec88](https://github.com/customcommander/project-blueprint/commit/c18ec888aedca7e58d477b367ea239dd1541f481))
118-
119-
## [1.0.1](https://github.com/customcommander/project-blueprint/compare/v1.0.0...v1.0.1) (2021-01-28)
120-
121-
122-
### Bug Fixes
123-
124-
* pass env vars to docker container in gh workflow ([28be287](https://github.com/customcommander/project-blueprint/commit/28be287f35ec971fe77457a54a1c402bde054877))
125-
126-
# 1.0.0 (2021-01-28)
127-
128-
129-
### Bug Fixes
130-
131-
* implement a basic build and release pipeline ([b1fa01f](https://github.com/customcommander/project-blueprint/commit/b1fa01f0212193e64529d7c9b2ef8b737b0a2c1a))

INSTALL.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
# Project Blueprint
1+
# Functionaut
22

3-
A template for managing the development lifecycle of a Node.js package.
4-
5-
## Why?
6-
7-
There are many things to think about and set up properly before you can start writing and publishing code. This template intends to give you enough of head start as starting from scratch always slows you down. If you don't know how or where to start or fear ["analysis paralysis"](https://en.wikipedia.org/wiki/Analysis_paralysis), this template could provide a handy escape hatch.
8-
9-
## What's in the box?
10-
11-
This template is entirely based on my own (insignificant) opinions on how to achieve a steady, healthy and sustainable development lifecycle. Some of my decisions are documented in [architecture decision records](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions). After you generate a repository from this template you are free to make _any_ changes you like but you'll be on your own.
12-
13-
### A development environment 100% dockerized
14-
15-
The main development container provides: Node.js 14, GNU Make, Git, JQ, Google Closure Compiler and ADR Tools. For an even better developer experience there is a `.devcontainer.json` file to spin up the development environment with the [VS Code Remote - Containers](https://code.visualstudio.com/docs/remote/containers) extension.
16-
17-
### Building
18-
19-
Make is the build tool. We use the Google Closure Compiler for compiling and bundling your Node.js library. A browser bundle is automatically generated too. [Tape](https://github.com/substack/tape) is used for testing.
20-
21-
### Release
22-
23-
On every push to your main branch (either `main` or `master`) a GitHub workflow will automatically publish a new version to both NPM and GitHub. The [semantic-release](https://github.com/semantic-release/semantic-release) tool automatically works out the next version by analysing your commit messages. A CHANGELOG file is automatically generated.
24-
25-
### Pull Request
26-
27-
A GitHub workflow runs all your tests against all pull requests.
28-
29-
### Documentation
30-
31-
We use [Slate](https://github.com/slatedocs/slate) to generate API documentation from your source files. A GitHub workflow automatically deploys to `gh-pages` on every push to your main branch. (Example https://customcommander.github.io/project-blueprint/)
32-
33-
### Architecture Decision Records (ADR)
34-
35-
Keeping a record of your architecture decisions is as important as writing and maintaining code. The development environment comes with [ADR Tools](https://github.com/npryce/adr-tools).
3+
A functional journey.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@customcommander/project-blueprint",
3-
"version": "1.8.1",
2+
"name": "@customcommander/functionaut",
3+
"version": "0.0.0",
44
"author": "customcommander <[email protected]>",
5-
"repository": "https://github.com/customcommander/project-blueprint.git",
6-
"description": "A template for managing the development lifecycle of a Node.js package",
5+
"repository": "https://github.com/customcommander/functionaut.git",
6+
"description": "A functional journey.",
77
"files": [
88
"dist/index.js",
99
"dist/browser.min.js"

src/curry.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license MIT
3+
* @copyright (c) 2021 Julien Gonzalez <[email protected]>
4+
*/
5+
6+
const {assert_function} = require('./private/helpers');
7+
8+
const _curry =
9+
fn => (...args) =>
10+
args.length >= fn.length
11+
? fn(...args)
12+
: _curry(fn.bind(null, ...args));
13+
14+
/**
15+
* @namespace
16+
* @alias ROOT
17+
*/
18+
module.exports = {
19+
20+
/**
21+
* Returns a curried version of `fn`.
22+
*
23+
* @example
24+
* ```javascript
25+
* const add = curry((a, b) => a + b);
26+
* const add10 = add(10);
27+
*
28+
* [1, 2, 3].map(add10);
29+
* //=> [11, 12, 13]
30+
* ```
31+
*
32+
* @public
33+
* @param {function()} fn Function to curry.
34+
* @return {function()}
35+
*/
36+
curry: fn => {
37+
assert_function(fn, 'curry: `fn` is not a function');
38+
return _curry(fn);
39+
}
40+
};

src/private.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/private/helpers.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const Throw =
2+
msg => { throw new Error(msg); };
3+
4+
const assert =
5+
pred => (x, err) =>
6+
pred(x) === true || Throw(err);
7+
8+
const assert_function =
9+
assert(x => typeof x === 'function');
10+
11+
module.exports =
12+
{ assert_function
13+
};

src/public-1.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)