File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,26 +118,6 @@ function get (obj, path) {
118118 return obj ;
119119}
120120
121- /**
122- * Set a nested property of an object.
123- *
124- * @param { object } obj The object to modify.
125- * @param { string[] } path The path to the property.
126- * @param { any } value The value to set.
127- */
128- function set ( obj , path , value ) {
129- const valueKey = path . pop ( ) ;
130- for ( const key of path ) {
131- let nested = obj [ key ] ;
132- if ( ! nested ) {
133- nested = { } ;
134- obj [ key ] = nested ;
135- }
136- obj = nested ;
137- }
138- obj [ valueKey ] = value ;
139- }
140-
141121/**
142122 * Deduplicate an array by a given key callback.
143123 * Item properties are merged recursively and with the preference for last defined values.
@@ -171,7 +151,6 @@ module.exports = {
171151 mergeDuplicatesPreferLast : mergeDuplicatesPreferLast ,
172152 numberToLetterSequence : numberToLetterSequence ,
173153 numberToRoman : numberToRoman ,
174- set : set ,
175154 splitClassesAndIds : splitClassesAndIds ,
176155 trimCharacter : trimCharacter
177156} ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const selderee = require('selderee');
66
77const { BlockTextBuilder } = require ( './block-text-builder' ) ;
88const defaultFormatters = require ( './formatter' ) ;
9- const { limitedDepthRecursive, mergeDuplicatesPreferLast, set } = require ( './helper' ) ;
9+ const { limitedDepthRecursive, mergeDuplicatesPreferLast } = require ( './helper' ) ;
1010
1111// eslint-disable-next-line import/no-unassigned-import
1212require ( './typedefs' ) ;
@@ -241,6 +241,19 @@ function handleDeprecatedOptions (options) {
241241 selectorDefinitions . push ( ...tagDefinitions ) ;
242242 }
243243
244+ function set ( obj , path , value ) {
245+ const valueKey = path . pop ( ) ;
246+ for ( const key of path ) {
247+ let nested = obj [ key ] ;
248+ if ( ! nested ) {
249+ nested = { } ;
250+ obj [ key ] = nested ;
251+ }
252+ obj = nested ;
253+ }
254+ obj [ valueKey ] = value ;
255+ }
256+
244257 function copyFormatterOption ( source , format , target ) {
245258 if ( options [ source ] === undefined ) { return ; }
246259 for ( const definition of selectorDefinitions ) {
You can’t perform that action at this time.
0 commit comments