Created
January 23, 2019 18:56
-
-
Save amilajack/ad811f928589a124b9bd6d507c6bca65 to your computer and use it in GitHub Desktop.
Revisions
-
amilajack created this gist
Jan 23, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ made with [esnextbin](http://esnextb.in) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ <!doctype html> <html> <head> <meta charset="utf-8"> <title>ESNextbin Sketch</title> <!-- put additional styles and scripts here --> </head> <body> <!-- put markup and other contents here --> <img src="" alt=""> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ function config(b = {}) { if (!b.extends || !b.extends.length) return b; if (!Array.isArray(b.extends)) throw new Error(".extends must be array"); let a = []; for (let i = 0; i < b.extends.length; i++) { b.extends[i] = config(b.extends[i]); } const f = Object.assign({}, ...b.extends.map(e => e), { ...b }); delete f.extends; return f; } console.log( config({ extends: [{ extends: [{ bar: "zoo", extends: [{ cow: "cow" }] }] }], bar: "bar" }) ); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ { "name": "esnextbin-sketch", "version": "0.0.0", "dependencies": { "babel-runtime": "6.26.0" } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ 'use strict'; var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); var _extends2 = require('babel-runtime/helpers/extends'); var _extends3 = _interopRequireDefault(_extends2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function config() { var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (!b.extends || !b.extends.length) return b; if (!Array.isArray(b.extends)) throw new Error('.extends must be array'); var a = []; for (var i = 0; i < b.extends.length; i++) { b.extends[i] = config(b.extends[i]); } var f = _extends3.default.apply(undefined, [{}].concat((0, _toConsumableArray3.default)(b.extends.map(function (e) { return e; })), [(0, _extends3.default)({}, b)])); delete f.extends; return f; } console.log(config({ extends: [{ extends: [{ bar: 'zoo', extends: [{ cow: 'cow' }] }] }], bar: 'bar' }));