made with esnextbin
Last active
October 19, 2016 15:24
-
-
Save aledoroshenko/f7f6b12e59189122ff2d3cf9bb62fbf5 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 _ from 'lodash'; | |
import expect from 'expect'; | |
var userIdentities = [ | |
{ | |
name: 'userIdentity1', | |
guid: '{EAC26C71-57B0-4EC3-972E-8A3A7AE3031B}' | |
}, | |
{ | |
name: 'userIdentity2', | |
guid: '{D945C58D-4253-4365-B75B-8D6831159D70}' | |
} | |
]; | |
var item = { | |
ncc_meta: { | |
owner: { | |
identity_id: '{D945C58D-4253-4365-B75B-8D6831159D70}' | |
} | |
} | |
}; | |
function getOwnerIdentityId(item) { | |
return _.get(item, 'ncc_meta.owner.identity_id', null) | |
} | |
function getOwnerIdentity(item) { | |
return _.find(userIdentities, { guid: getOwnerIdentityId(item) }); | |
} | |
console.log('fired ', getOwnerIdentity(item)); | |
expect(getOwnerIdentity(item).name).toEqual('userIdentity2'); |
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", | |
"dependecies": { | |
"lodash": "~4.14.1", | |
"expect": "~1.20.2" | |
}, | |
"dependencies": { | |
"lodash": "4.16.4", | |
"expect": "1.20.2" | |
} | |
} |
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 _lodash = require('lodash'); | |
var _lodash2 = _interopRequireDefault(_lodash); | |
var _expect = require('expect'); | |
var _expect2 = _interopRequireDefault(_expect); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var userIdentities = [{ | |
name: 'userIdentity1', | |
guid: '{EAC26C71-57B0-4EC3-972E-8A3A7AE3031B}' | |
}, { | |
name: 'userIdentity2', | |
guid: '{D945C58D-4253-4365-B75B-8D6831159D70}' | |
}]; | |
var item = { | |
ncc_meta: { | |
owner: { | |
identity_id: '{D945C58D-4253-4365-B75B-8D6831159D70}' | |
} | |
} | |
}; | |
function getOwnerIdentityId(item) { | |
return _lodash2.default.get(item, 'ncc_meta.owner.identity_id', null); | |
} | |
function getOwnerIdentity(item) { | |
return _lodash2.default.find(userIdentities, { guid: getOwnerIdentityId(item) }); | |
} | |
console.log('fired ', getOwnerIdentity(item)); | |
(0, _expect2.default)(getOwnerIdentity(item).name).toEqual('userIdentity2'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment