From 680d9e474aeedc987b1ceb8ef83653687b362455 Mon Sep 17 00:00:00 2001 From: Evgeny Metelkin Date: Wed, 8 Nov 2023 14:12:29 +0200 Subject: [PATCH] remove _.defaults --- src/container/actions.js | 20 ++++++++++---------- src/core/component.js | 12 ++++++------ src/core/top.js | 7 +++---- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/container/actions.js b/src/container/actions.js index 8e99b384..e02503d6 100644 --- a/src/container/actions.js +++ b/src/container/actions.js @@ -133,11 +133,11 @@ Container.prototype.insert = function(q = {}, isCore = false){ let exportCheck = q.class.match(/^(\w+)Export$/); if (exportCheck !== null) { // check if old export syntax is used this.logger.warn(`Usage of Export is deprecated starting from v0.5.0, use syntax: #export {format: ${exportCheck[1]}, ...}`) - let exportQ = _.omit(q, ['class', 'id']); - _.defaults(exportQ, { + let _exportQ = _.omit(q, ['class', 'id']); + let exportQ = Object.assign({ format: exportCheck[1], filepath: q.id - }); + }, _exportQ); return this.export(exportQ); } @@ -356,12 +356,12 @@ Container.prototype.setNS = function(q = {}){ * * @returns {Component[]} Array of cloned components. */ -Container.prototype.importNS = function(q = {}){ - _.defaults(q, { +Container.prototype.importNS = function(_q = {}){ + let q = Object.assign({ prefix: '', suffix: '', rename: {} - }); + }, _q); let space = q.space || 'nameless'; if (q.fromId) { @@ -459,14 +459,14 @@ Container.prototype.moveNS = function(q = {}){ * * @returns {Component} Cloned component. */ -Container.prototype.import = function(q = {}){ - let ind = getIndexFromQ(q); +Container.prototype.import = function(_q = {}){ + let ind = getIndexFromQ(_q); - _.defaults(q, { + let q = Object.assign({ prefix: '', suffix: '', rename: {} - }); + }, _q); let space = q.space || 'nameless'; // checking arguments diff --git a/src/core/component.js b/src/core/component.js index 2f964842..452da0fe 100644 --- a/src/core/component.js +++ b/src/core/component.js @@ -84,13 +84,13 @@ class Component { return componentClone; } /** Change referencies of component based on suffix/prefix/rename */ - updateReferences(q = {}){ + updateReferences(_q = {}){ // set defaults - _.defaults(q, { + let q = Object.assign({ prefix: '', suffix: '', rename: {} - }); + }, _q); // change references const iterator = (item, path) => { // Actor { target: 'y', stoichiometry: -1 }, actors[0].target @@ -222,13 +222,13 @@ class Component { return res; } - toFlat(options = {}){ + toFlat(_options = {}){ // set defaults - _.defaults(options, { + let options = Object.assign({ simplifyModifiers: true, simplifyActors: true, simplifyExpressions: true - }); + }, _options); let q = this.toQ(options); let res = flatten(q); diff --git a/src/core/top.js b/src/core/top.js index 50b49540..d203de68 100644 --- a/src/core/top.js +++ b/src/core/top.js @@ -2,7 +2,6 @@ Top class for all other items of platform */ -const _ = require('lodash'); const randomId = require('random-id'); const { ajv } = require('../utils'); const { flatten } = require('./utilities'); @@ -91,13 +90,13 @@ class Top { // or const Top = class {...} return q; } - toFlat(options = {}){ + toFlat(_options = {}){ // set defaults - _.defaults(options, { + let options = Object.assign({ simplifyModifiers: true, simplifyActors: true, simplifyExpressions: true - }); + }, _options); let q = this.toQ(options); let res = flatten(q);