UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

54 lines 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Record = void 0; /** * Helper for transforming records. */ exports.Record = { /** * Returns an array of the names of the properties of a record. * @param object - The record to get the property names from. */ keys(object) { return Object.keys(object); }, /** * Returns an array of the values of the properties of a record. * @param object - The record to get the property values from. */ values(object) { return Object.values(object); }, /** * Returns an array of the key-value pairs of the properties of a record. * @param object - The record to get the properties from. */ entries(object) { return Object.entries(object); }, /** * Transforms a record by applying a callback function to each key-value pair in the record. * @param object - The record that should be transformed. * @param callbackfn - The callback function that transforms each key-value pair of the record. */ map(object, callbackfn) { return Object.fromEntries(exports.Record.entries(object).map(callbackfn)); }, /** * Transforms a record by applying a callback function to each key in the record. * @param object - The record that should be transformed. * @param callbackfn - The callback function that transforms each key of the record. */ mapKeys(object, callbackfn) { return exports.Record.map(object, ([key, value], index, entries) => [callbackfn(key, index, entries), value]); }, /** * Transforms a record by applying a callback function to each property value in the record. * @param object - The record that should be transformed. * @param callbackfn - The callback function that transforms each property value of the record. */ mapProperties(object, callbackfn) { return exports.Record.map(object, ([keys, value], index, entries) => [keys, callbackfn(value, index, entries)]); } }; //# sourceMappingURL=record.js.map