mirror of
https://github.com/HeyPuter/puter.git
synced 2026-07-16 12:07:05 +00:00
fix: objutil
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
const { config } = require("yargs");
|
||||
const { whatis } = require("./langutil");
|
||||
|
||||
const DO_NOT_DEFINE = Symbol('DO_NOT_DEFINE');
|
||||
@@ -15,7 +14,7 @@ const createTransformedValues = (input, options = {}, state = {}) => {
|
||||
for ( let i=0 ; i < input.length; i++ ) {
|
||||
const value = input[i];
|
||||
state.keys.push(i);
|
||||
output.push(createTransformedValues(value, options));
|
||||
output.push(createTransformedValues(value, options, state));
|
||||
state.keys.pop();
|
||||
}
|
||||
return output;
|
||||
@@ -25,7 +24,7 @@ const createTransformedValues = (input, options = {}, state = {}) => {
|
||||
Object.setPrototypeOf(output, input);
|
||||
for ( const k in input ) {
|
||||
state.keys.push(k);
|
||||
const new_value = createTransformedValues(input[k], options);
|
||||
const new_value = createTransformedValues(input[k], options, state);
|
||||
if ( new_value !== DO_NOT_DEFINE ) {
|
||||
output[k] = new_value;
|
||||
}
|
||||
@@ -40,20 +39,6 @@ const createTransformedValues = (input, options = {}, state = {}) => {
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
config.__set_config_object__(createTransformedValues(config, {
|
||||
mutateValue: (input, { state }) => {
|
||||
const path = state.keys.join('.'); // or jq
|
||||
// ....
|
||||
if ( should_replace ) {
|
||||
return 'replacement';
|
||||
} else {
|
||||
return DO_NOT_DEFINE;
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
module.exports = {
|
||||
createTransformedValues,
|
||||
DO_NOT_DEFINE,
|
||||
|
||||
Reference in New Issue
Block a user