How to use the dot-prop.delete function in dot-prop

To help you get started, we’ve selected a few dot-prop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vivocha / arrest / src / utils.ts View on Github external
function moveDefinition(spec: any, newSchemaKey: string, path: string): any {
  // copy the definition to components.schemas root
  const defSchema = dot.get(spec, path);
  dot.set(spec, `components.schemas.${newSchemaKey}`, defSchema);
  // delete the definition at current path
  dot.delete(spec, path);
  const newRef = `#/components/schemas/${newSchemaKey}`;
  return updateRefs(spec, `#/${path.split('.').join('/')}`, newRef);
}
github vivocha / arrest / src / utils.ts View on Github external
// current schema was the last reference in the other schema referencing it, then remove also that schema
        dot.delete(spec as any, referencedByPath);
      } else {
        // or, update the referencing schema removing the current schema:
        // remove the entry from the referencedBy array in occurrences table
        _.remove(referencedBy[referencedByKey].referencedBy, v => v === referencedByPath);
        // update occurrence to save in occurrences table
        const updatedOccurrence = {
          count: referencedBy[referencedByKey].count - 1,
          referencedBy: referencedBy[referencedByKey].referencedBy
        };
        dot.set(occurrences['schemas'] as any, referencedByKey, updatedOccurrence);
      }
    }
    // finally, delete the current schema with count === 0
    dot.delete(spec as any, pathToDelete);
  }
  return spec;
}
github vivocha / arrest / src / utils.ts View on Github external
function rebaseOASDefinition(fullSpec: any, schemaKey: string, schema: any, path: string, definitionsPath: string[]): any {
  if (schema.definitions) {
    for (const defKey in schema.definitions) {
      // current recursive definition path chain
      const chain = [...definitionsPath, defKey];
      const newPath = `${path}.definitions.${defKey}`;
      const definition = dot.get(fullSpec, newPath);
      fullSpec = rebaseOASDefinition(fullSpec, defKey, definition, newPath, chain);
      const newSchemaName = `${chain.join('_')}`;
      // move to components/schemas and get a new ref related to the new path
      fullSpec = moveDefinition(fullSpec, newSchemaName, newPath);
    }
    dot.delete(fullSpec, `${path}.definitions`);
  }
  return fullSpec;
}
github lerna / lerna / core / project / lib / deprecate-config.js View on Github external
return obj => {
    for (const searchPath of pathsToSearch) {
      if (dotProp.has(obj.config, searchPath)) {
        const fromVal = dotProp.get(obj.config, searchPath);
        const toVal = toValue ? toValue(fromVal) : fromVal;

        log.warn("project", deprecationMessage(obj, target, searchPath, fromVal, toVal));

        dotProp.set(obj.config, target, toVal);
        dotProp.delete(obj.config, searchPath);
      }
    }

    return obj;
  };
}
github omenking / swap-n-pop / src / common / store.ts View on Github external
delete(key) {
		const data = this.data
		DotProp.delete(data, key)
		this.data = data
	}
	clear() {
github vivocha / arrest / src / utils.ts View on Github external
function deleteUnreferencedParameters(occurrences: any, spec: OpenAPIV3.Document): OpenAPIV3.Document {
  const toDelete = Object.keys(_.pickBy(occurrences['parameters'], value => value.count === 0));
  for (const paramName of toDelete) {
    dot.delete(spec as any, `components.parameters.${paramName}`);
  }
  return spec;
}
github vadimdemedes / mongorito / lib / fields.js View on Github external
arrify(key).forEach(key => {
			dotProp.delete(this.fields, key);
		});
	}
github yeoman / configstore / index.js View on Github external
delete(key) {
		const config = this.all;
		dotProp.delete(config, key);
		this.all = config;
	}
github wordup-dev / wordup-cli / src / lib / config.js View on Github external
remove(key) {
    const config = this.getConfig()
    dotProp.delete(config, key)
    fs.writeJsonSync(this.configFile, config, {spaces: 4})
  }
}
github chinedufn / solid-state / index.js View on Github external
State.prototype.del = function (key) {
  dotProp.delete(this.__ImmutableState__, key)
  this.listeners(this.get())
}

dot-prop

Get, set, or delete a property from a nested object using a dot path

MIT
Latest version published 10 months ago

Package Health Score

80 / 100
Full package analysis