Skip to content

Commit

Permalink
Update Node and Fluture to version 12
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaq committed Oct 10, 2019
1 parent 235a137 commit d6295e7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/index.js
/coverage/
/index.cjs
/node_modules/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "10"
- "12"
27 changes: 12 additions & 15 deletions index.mjs → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
//. forking it, it can be composed with other Futures using `map`, `ap`,
//. `bimap`, and `chain`, or any of the other functions provided by Fluture.

import {reject, map, chain} from 'fluture';
import {hookAll, acquire, Hook} from 'fluture-hooks';
import {map, chain} from 'fluture/index.js';
import {hookAll, Hook} from 'fluture-hooks/index.js';

// hasProp :: Object ~> String -> Boolean
const hasProp = Object.prototype.hasOwnProperty;
Expand Down Expand Up @@ -141,7 +141,6 @@ const check = bootstrappers => {
), {path: path.concat([name]), checked, flaws});

return {path, checked: subs.checked.concat([name]), flaws: subs.flaws};

}

const {flaws} = bootstrappers.reduce(validateTree, {path: [], flaws: [], checked: []});
Expand All @@ -154,21 +153,19 @@ const check = bootstrappers => {
}

const callBootstrappers = (bootstrappers, resources) => (
map(
xs => xs.reduce((acc, {resource, name}) => ({...acc, [name]: resource}), resources),
hookAll(bootstrappers.map(
({name, bootstrap}) => map(resource => ({resource, name}), bootstrap(resources))
))
)
map (xs => xs.reduce ((acc, {resource, name}) => ({...acc, [name]: resource}), resources))
(hookAll (bootstrappers.map (
({name, bootstrap}) => map (resource => ({resource, name})) (bootstrap (resources))
)))
);

const complete = (bootstrappers, hookResources) => (
bootstrappers.length === 0 ? hookResources : chain(resources => {
const pred = ({needs}) => needs.every(need => hasProp.call(resources, need));
const layer = bootstrappers.filter(pred);
const remainder = bootstrappers.filter(x => !pred(x));
return complete(remainder, callBootstrappers(layer, resources));
}, hookResources)
bootstrappers.length === 0 ? hookResources : chain (resources => {
const pred = ({needs}) => needs.every (need => hasProp.call (resources, need));
const layer = bootstrappers.filter (pred);
const remainder = bootstrappers.filter (x => ! pred (x));
return complete (remainder, callBootstrappers (layer, resources));
}) (hookResources)
);

//. ## API
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
"name": "booture",
"version": "1.0.1",
"description": "Application bootstrapping on top of Fluture Hooks",
"main": "index",
"module": "index.mjs",
"type": "module",
"main": "index.cjs",
"module": "index.js",
"scripts": {
"build": "rollup -c rollup.config.mjs",
"build": "rollup -c rollup.config.js",
"release": "xyz --edit --script scripts/prerelease --increment",
"test": "node --experimental-modules --no-warnings --stack-trace-limit=100 ./test/index.mjs"
"test": "c8 --check-coverage --branches 96 --functions 100 --lines 100 --statements 100 node --experimental-modules --no-warnings ./node_modules/.bin/oletus"
},
"repository": {
"type": "git",
"url": "git://github.com/fluture-js/booture.git"
},
"files": [
"/index.cjs",
"/index.js",
"/index.mjs",
"/LICENSE",
"/package.json",
"/README.md"
Expand All @@ -24,12 +25,14 @@
"license": "MIT",
"dependencies": {},
"peerDependencies": {
"fluture": ">=10.0.0 <12.0.0",
"fluture-hooks": ">=0.2.0 <2.0.0"
"fluture": ">=12.0.0-beta.4 <13.0.0",
"fluture-hooks": ">=2.0.0 <3.0.0"
},
"devDependencies": {
"fluture": "^11.0.0",
"fluture-hooks": "^1.0.0",
"c8": "^5.0.4",
"fluture": "^12.0.0-beta.4",
"fluture-hooks": "github:fluture-js/fluture-hooks#avaq/fluture-node-12",
"oletus": "^2.0.0",
"rollup": "^1.1.0",
"transcribe": "^1.1.1",
"xyz": "^3.0.0"
Expand Down
18 changes: 18 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
input: 'index.js',
external: ['fluture/index.js', 'fluture-hooks/index.js'],
output: {
format: 'umd',
name: 'booture',
file: 'index.cjs',
interop: false,
paths: {
'fluture/index.js': 'fluture',
'fluture-hooks/index.js': 'fluture-hooks',
},
globals: {
'fluture/index.js': 'Fluture',
'fluture-hooks/index.js': 'flutureHooks'
}
}
};
19 changes: 0 additions & 19 deletions rollup.config.mjs

This file was deleted.

37 changes: 21 additions & 16 deletions test/index.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {deepStrictEqual, throws} from 'assert';
import {deepStrictEqual} from 'assert';
import {inspect} from 'util';
import {fork, resolve, debugMode} from 'fluture';
import {acquire, runHook} from 'fluture-hooks';
import {bootstrap} from '..';
import {fork, resolve, debugMode} from 'fluture/index.js';
import {acquire, runHook} from 'fluture-hooks/index.js';
import {bootstrap} from '../index.js';
import test from 'oletus';

debugMode (true);

Expand Down Expand Up @@ -33,19 +34,23 @@ const flawed = {
]
};

Object.entries(flawed).forEach(([message, bootstrappers]) => {
throws (() => bootstrap (bootstrappers)
, new TypeError(`Flawed dependency graph:\n${message}`));
test ('flawed graph', ({throws}) => {
Object.entries(flawed).forEach(([message, bootstrappers]) => {
throws (() => bootstrap (bootstrappers)
, new TypeError(`Flawed dependency graph:\n${message}`));
});
});

fork (fail)
(eq ({}))
(runHook (bootstrap ([])) (resolve));
test ('valid graph', () => {
fork (fail)
(eq ({}))
(runHook (bootstrap ([])) (resolve));

fork (fail)
(eq ({x: 42}))
(runHook (bootstrap ([make('x', [])])) (resolve));
fork (fail)
(eq ({x: 42}))
(runHook (bootstrap ([make('x', [])])) (resolve));

fork (fail)
(eq ({x: 42, y: 42}))
(runHook (bootstrap ([make('x', ['y']), make('y', [])])) (resolve));
fork (fail)
(eq ({x: 42, y: 42}))
(runHook (bootstrap ([make('x', ['y']), make('y', [])])) (resolve));
});

0 comments on commit d6295e7

Please sign in to comment.