Skip to content

Instantly share code, notes, and snippets.

View xiaoyvr's full-sized avatar

Yu Xiaoqiang xiaoyvr

  • ThoughtWorks
  • Dallas
View GitHub Profile
@xiaoyvr
xiaoyvr / DSL of setValueOf
Last active December 22, 2015 00:38
DSL of setValueOf
function setValueOf(fieldName, obj) {
var originVal = obj[fieldName] || {};
var getters = [];
var builder = {
inRange: function (collection, findKey) {
getters.push(function () {
return _.find(collection, function (i) {
return findKey ? (i[findKey] === originVal[findKey]) : (i === originVal);
});
});
function include($dep){
if(-not $__includeContainer){
$__includeContainer = New-Object "system.collections.generic.hashset[string]"
}
$folder = Split-Path $MyInvocation.ScriptName -Parent
$searchPaths = $folder, $__searchPaths
foreach($path in $searchPaths){
if(Test-Path "$path\$dep.ps1"){
$file = "$path\$dep.ps1"