made with esnextbin
Last active
October 16, 2016 08:13
-
-
Save aledoroshenko/12116845a9daf3aa6a743889a36e6ede to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains 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 characters
<!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 --> | |
</body> | |
</html> |
This file contains 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 characters
import path from 'path'; | |
import expect from 'expect'; | |
import _ from 'lodash'; | |
var obj = {a: [], b: [1,2], c: [], d: [1]}; | |
var filteredObj = _.pickBy(obj, function(val){ | |
return val.length > 0; | |
}); | |
var filteredObj2 = _.omitBy(obj, _.isEmpty); | |
expect(filteredObj).toEqual({b: [1,2], d: [1]}) | |
expect(filteredObj2).toEqual({b: [1,2], d: [1]}) | |
console.log(filteredObj2) | |
console.log('Tests passed'); |
This file contains 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 characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"expect": "1.20.2", | |
"lodash": "4.13.1", | |
"undefined": "v4.5.0" | |
} | |
} |
This file contains 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 characters
'use strict'; | |
var _path = require('path'); | |
var _path2 = _interopRequireDefault(_path); | |
var _expect = require('expect'); | |
var _expect2 = _interopRequireDefault(_expect); | |
var _lodash = require('lodash'); | |
var _lodash2 = _interopRequireDefault(_lodash); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var obj = { a: [], b: [1, 2], c: [], d: [1] }; | |
var filteredObj = _lodash2.default.pickBy(obj, function (val) { | |
return val.length > 0; | |
}); | |
var filteredObj2 = _lodash2.default.omitBy(obj, _lodash2.default.isEmpty); | |
(0, _expect2.default)(filteredObj).toEqual({ b: [1, 2], d: [1] }); | |
(0, _expect2.default)(filteredObj2).toEqual({ b: [1, 2], d: [1] }); | |
console.log(filteredObj2); | |
console.log('Tests passed'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment