mezzanine
Version:
Fantasy land union types with pattern matching
54 lines (32 loc) • 1.24 kB
JavaScript
import { toPairs, pipe } from 'ramda';
import { toJSON } from './fixtures';
import { fantasyStatic, fantasyMethods } from './fantasy-land';
import '../utils/props';
import
'./type-container';
export var iterator =
ctx => function* iterator() {
for (var _iterator = ctx.keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {var _ref;if (_isArray) {if (_i >= _iterator.length) break;_ref = _iterator[_i++];} else {_i = _iterator.next();if (_i.done) break;_ref = _i.value;}var key = _ref; //TODO Replace with more useful values
//$FlowIssue
yield [key, ctx[key]];}
};
export var instanceInjectableProps = {
toJSON: {
value(ctx) {
//$FlowIssue
return () => toJSON(ctx);
},
writable: true,
enumerable: false,
inject: true },
//$FlowIssue
[Symbol.hasInstance]: ctx => val => ctx.is(val),
//$ FlowIssue
[Symbol.iterator]: iterator };
var prepareFl = pipe(
toPairs,
//$ FlowIssue
arr => arr.concat(arr.map(([name, value]) => [`fantasy-land/${name}`, value])));
export var fantasyInstance = prepareFl(fantasyMethods);
export var fantasyOnClass = prepareFl(fantasyStatic);
//# sourceMappingURL=properties.js.map