krl-stdlib
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "krl-stdlib", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Standard library for KRL", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -9,3 +9,3 @@ var _ = require("lodash"); | ||
stdlib[op] = function(){ | ||
if(arguments.length === 0){ | ||
if(arguments.length === 1){ | ||
return; | ||
@@ -401,2 +401,10 @@ } | ||
stdlib["get"] = function(ctx, obj, path) { | ||
return _.get(obj,path); | ||
}; | ||
stdlib["set"] = function(ctx, obj, path, val) { | ||
return _.set(obj,path,val); | ||
}; | ||
module.exports = stdlib; |
@@ -291,2 +291,34 @@ var _ = require("lodash"); | ||
tf("get", [obj, ["foo", "bar", "10"]], "I like cheese"); | ||
tf("get", [obj, "colors"], "many"); | ||
assertObjNotMutated(); | ||
// note that the "set" tests mutates the obj | ||
tf("set", [obj, ["foo", "baz"], "qux"], { | ||
"colors": "many", | ||
"pi": [3, 1, 4, 1, 5, 6, 9], | ||
"foo": { | ||
"bar": {"10": "I like cheese"}, | ||
"baz": "qux" | ||
} | ||
}); | ||
tf("set", [obj, "flop", 12], { | ||
"colors": "many", | ||
"pi": [3, 1, 4, 1, 5, 6, 9], | ||
"foo": { | ||
"bar": {"10": "I like cheese"}, | ||
"baz": "qux" | ||
}, | ||
"flop": 12 | ||
}); | ||
tf("set", [obj, "colors", ["R", "G", "B"]], { | ||
"colors": ["R", "G", "B"], | ||
"pi": [3, 1, 4, 1, 5, 6, 9], | ||
"foo": { | ||
"bar": {"10": "I like cheese"}, | ||
"baz": "qux" | ||
}, | ||
"flop": 12 | ||
}); | ||
tf("intersection", [[2, 1], [2, 3]], [2]); | ||
@@ -293,0 +325,0 @@ |
23160
727