feat: get/set

This commit is contained in:
cha0s 2021-02-03 13:53:49 -06:00
parent 20b52ee997
commit ad67ee5d90
2 changed files with 45 additions and 1 deletions

View File

@ -24,7 +24,9 @@
"autoprefixer": "^9.8.6",
"debug": "4.3.1",
"deepmerge": "^4.2.2",
"lodash.mapvalues": "^4.6.0"
"lodash.get": "^4.4.2",
"lodash.mapvalues": "^4.6.0",
"lodash.set": "^4.3.2"
},
"devDependencies": {
"@avocado/entity": "^2.0.0",

View File

@ -1,4 +1,6 @@
import merge from 'deepmerge';
import get from 'lodash.get';
import set from 'lodash.set';
export default {
@ -15,6 +17,24 @@ export default {
],
vararg: true,
},
get: {
label: 'get',
type: 'any',
args: [
{
label: 'object',
type: 'object',
},
{
label: 'path',
type: 'string',
},
{
label: 'default',
type: 'any',
},
],
},
makeObject: {
label: '{}',
type: 'object',
@ -34,10 +54,30 @@ export default {
}
},
},
set: {
label: 'set',
type: 'void',
args: [
{
label: 'object',
type: 'object',
},
{
label: 'path',
type: 'string',
},
{
label: 'value',
type: 'any',
},
],
},
},
type: 'object',
}),
get: (object, path, defaultValue) => get(object, path, defaultValue),
log: (...args) => {
// eslint-disable-next-line no-console
console.log(...args);
@ -63,4 +103,6 @@ export default {
merge: (l, r) => merge(l, r),
set: (object, path, value) => set(object, path, value),
};