How to use the clone function from underscore

Find comprehensive JavaScript underscore.clone code examples handpicked from public code repositorys.

738
739
740
741
742
743
744
745
746
747
    }

})

//делаем объект для USD на основе USDT
var usd = _.clone(array['PKOIN_USDT'])

if (typeof highest_price !== Number) {
    highest_price = parseFloat(highest_price, 10).toFixed(2)
} 
fork icon33
star icon58
watch icon7

+ 2 other calls in file

195
196
197
198
199
200
201
202
203
function endMiddleware(entity, typeInformation, callback) {
    callback(null, entity);
}

if (middlewareCollection && middlewareCollection.length > 0) {
    const middlewareList = _.clone(middlewareCollection);

    middlewareList.unshift(emptyMiddleware);
    middlewareList.push(endMiddleware);
fork icon74
star icon56
watch icon23

260
261
262
263
264
265
266
267
268
269
        }
    );
}

function prepareDeviceData(deviceObj, configuration, callback) {
    const deviceData = _.clone(deviceObj);
    let selectedConfiguration;

    if (!deviceData.type) {
        if (configuration && configuration.type) {
fork icon74
star icon56
watch icon23

711
712
713
714
715
716
717
718
719
720
let clone = new Card(this.owner, this.cardData);
clone.upgrades = this.upgrades.map((upgrade) => upgrade.createSnapshot());
// clone.dieUpgrades = this.dieUpgrades.map((die) => die.createSnapshot());
clone.effects = _.clone(this.effects);
clone.tokens = _.clone(this.tokens);
clone.flags = _.clone(this.flags);
clone.controller = this.controller;
clone.location = this.location;
clone.parent = this.parent;
clone.modifiedAttack = this.getAttack();
fork icon9
star icon10
watch icon1

+ 2 other calls in file

379
380
381
382
383
384
385
386
387
388
//var read    = crud.read;
//var readAll = crud.readAll;
//var update  = crud.update;
//var del     = crud.del;

var unCrud = _.clone( crud );

return function _unPrefixCrud( req ){

    var website = req.kern.website;
fork icon3
star icon9
watch icon1

+ 5 other calls in file

289
290
291
292
293
294
295
296
297
298
  return entryTime(entry) - total;
};

var injectOtherTime = function (entry) {
  var name = "other " + entryName(entry);
  var other = _.clone(entry);
  other.push(name);
  bucketTimes[JSON.stringify(other)] = otherTime(entry);
  entries.push(other);
};
fork icon0
star icon7
watch icon4

+ 5 other calls in file

2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
}

const sourceFile = req.body.source.trim();
const sourceModule = req.body.module.trim();
validateUrl = proc.url + proc.validateTopModulePath;
requestBody = _.clone(req.body);
delete requestBody.user;
requestBody.username = ownerName;
requestBody.reponame = repoName;
res.socket.setTimeout(requestTimeout);
fork icon0
star icon2
watch icon3

+ 20 other calls in file

487
488
489
490
491
492
493
494
495
 * Shallow clone message and payload
 * @param {Object} message
 * @return {Object}
 */
cloneMessage: function(message) {
  var cloned = _.clone(message);
  cloned.payload = _.clone(message.payload);
  return message;
},
fork icon0
star icon1
watch icon1

32
33
34
35
36
37
38
39
40
41
//if (req.body.request != null && req.body.request != null) {
  // eslint-disable-next-line no-console
  //console.log(prettyjson.render(req.body.request));
//}

var cloned = _.clone(req.body);

// include http response in the original message, will be used to send response
cloned.getResponse = function() {
  return res;
fork icon0
star icon1
watch icon1

29
30
31
32
33
34
35
36
37
38
console.log('>> createTable', name);

T.increments('id').primary();

_.each(schema[name], function(props, column){
	var pt = _.clone(props.type);
	var columnType =  pt;
	var args = [column];

	if(_.isArray(pt)){
fork icon0
star icon1
watch icon4

+ 11 other calls in file

121
122
123
124
125
126
127
128
129
130
request: function (urlOrOptions, callback) {
  var options;
  if (!_.isObject(urlOrOptions))
    options = { url: urlOrOptions };
  else
    options = _.clone(urlOrOptions);

  var bodyStream;
  if (_.has(options, 'bodyStream')) {
    bodyStream = options.bodyStream;
fork icon0
star icon0
watch icon2

110
111
112
113
114
115
116
117
118
119
var self = this;
if (self.alwaysFire)
  return;
if (_.isEmpty(options.include))
  return;
var contents = _.clone(options.contents);
if (contents)
  contents.sort();

self.directories.push({
fork icon0
star icon0
watch icon10

+ 3 other calls in file

186
187
188
189
190
191
192
193
194
195

var child_process = require('child_process');

if (! self.program) {
  // Old-style bundle
  var opts = _.clone(self.nodeOptions);
  opts.push(path.join(self.bundlePath, 'main.js'));

  opts.push(
    '--parent-pid',
fork icon0
star icon0
watch icon0

216
217
218
219
220
221
222
223
224
225
//
// Commands should never call process.exit()! They should instead
// return an appropriate value.

main.registerCommand = function (options, func) {
  options = _.clone(options);
  options.func = func;

  var nameParts = options.name.trim().split(/\s+/);
  options.name = nameParts.join(' ');
fork icon0
star icon0
watch icon1

149
150
151
152
153
154
155
156
157
  var ret = new WatchSet;

  // XXX doesn't bother to deep-clone the directory info
  // #WatchSetShallowClone
  ret.alwaysFire = self.alwaysFire;
  ret.files = _.clone(self.files);
  ret.directories = _.clone(self.directories);
  return ret;
},
fork icon0
star icon0
watch icon14

+ 35 other calls in file

239
240
241
242
243
244
245
246
247
248
249
 * @param  {object} entry           A cache entry corresponding to the resfreshResponse.
 * @param  {object} refreshResponse The response from a token refresh request for the entry parameter.
 * @return {object}                 A new cache entry.
 */
CacheDriver.prototype._createEntryFromRefresh = function(entry, refreshResponse) {
  var newEntry = _.clone(entry);
  newEntry = _.extend(newEntry, refreshResponse);


  if (entry.isMRRT && this._authority !== entry[METADATA_AUTHORITY]) {
    newEntry[METADATA_AUTHORITY] = this._authority;
fork icon0
star icon0
watch icon0

113
114
115
116
117
118
119
120
121
122
123


SequenceValues.prototype.withValue = function(rule, value) {
    if (rule.captureName && rule.captureName in this._values) {
        throw new Error("Cannot add second value for capture \"" + rule.captureName + "\"");
    } else {
        var newValues = _.clone(this._values);
        newValues[rule.captureName] = value;
        var newValuesArray = this._valuesArray.concat([value]);
        return new SequenceValues(newValues, newValuesArray);
    }
fork icon0
star icon0
watch icon1

195
196
197
198
199
200
201
202
203
204
    return Promise.reject(error);
}

try {
    var transaction = helpers.formatters.inputCallFormatter(
        _.clone(tx)
    );
    transaction.to = transaction.to || "0x";
    transaction.data = transaction.data || "0x";
    transaction.value = transaction.value || "0x";
fork icon0
star icon0
watch icon5

+ 3 other calls in file

314
315
316
317
318
319
320
321
322
323
  }
}

if (options.switch && !options.jsonPathSwitchResponse) {
  options = _.clone(options);
  originalOptions = _.clone(options);
  apiMocker.setSwitchOptions(options, req);
  mockPath = path.join(apiMocker.options.mockDirectory, options.mockFile || '');
  if (!fs.existsSync(mockPath)) {
    apiMocker.logger.warn(
fork icon0
star icon0
watch icon1

+ 11 other calls in file

835
836
837
838
839
840
841
842
843
844
    isKeyStaff : true,
    isSuperUser : keystaffData.isSuperUser
}
if(payload.isForgot)
{
    let tempformdata = _.clone(formData);
    tempformdata.isKeystaff = true;
    let authToken = jwt.sign({
        data: tempformdata
    }, secretKey, { expiresIn: appConfig.jwtTempExpiry },{ algorithm: 'HS256'});
fork icon0
star icon0
watch icon1