diff --git a/src/lodash_idl.ts b/src/lodash_idl.ts index fe79aa9..b7ed3e5 100644 --- a/src/lodash_idl.ts +++ b/src/lodash_idl.ts @@ -59,6 +59,7 @@ const lodashProps = ` get: Path mapValues: Path + compute: Path # Creates an array of values corresponding to paths of object. at: [Path!] diff --git a/src/transformations.ts b/src/transformations.ts index 7093010..76e7020 100644 --- a/src/transformations.ts +++ b/src/transformations.ts @@ -30,6 +30,7 @@ import maxBy from 'lodash-es/maxBy'; import meanBy from 'lodash-es/meanBy'; import sumBy from 'lodash-es/sumBy'; import join from 'lodash-es/join'; +import expression from 'lodash-es/join'; import get from 'lodash-es/get'; import mapValues from 'lodash-es/mapValues'; @@ -40,10 +41,17 @@ import invertBy from 'lodash-es/invertBy'; import keys from 'lodash-es/keys'; import values from 'lodash-es/values'; +const compute = function(scope, expression) { + return _.template("<%= " + expression + " %>")(scope); +} + const transformations = { Array: { each: (array, arg) => { return map(array, item => applyTransformations(item, arg)); + }, + mapCompute: (array, arg) => { + return compute(array, item => applyTransformations(item, arg)); }, map, keyBy, @@ -84,6 +92,7 @@ const transformations = { invertBy, keys, values, + compute, }, Number: { lt,