Sha256: df7e5ea20c711b0809519c6dd1203460017f4ca2f232748a0679e3af36182557

Contents?: true

Size: 524 Bytes

Versions: 10

Compression:

Stored size: 524 Bytes

Contents

/**
 * The MIT License (MIT)
 * Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
 */

'use strict';

/**
 * Performs a deep copy of an simple object.
 * Only handles scalar values, arrays and objects.
 *
 * @param obj Object
 */

module.exports = function clone(obj) {
  if (obj === null || typeof obj !== 'object') {
    return obj;
  }
  var res = void 0;
  if (Array.isArray(obj)) {
    res = [];
  } else {
    res = {};
  }
  for (var i in obj) {
    res[i] = clone(obj[i]);
  }
  return res;
};

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
condenser-0.0.8 lib/condenser/processors/node_modules/regexp-tree/dist/utils/clone.js
jester-data-8.0.0 node_modules/regexp-tree/dist/utils/clone.js
ezii-os-5.2.1 node_modules/regexp-tree/dist/utils/clone.js
ezii-os-2.0.1 node_modules/regexp-tree/dist/utils/clone.js
ezii-os-1.1.0 node_modules/regexp-tree/dist/utils/clone.js
ezii-os-1.0.0 node_modules/regexp-tree/dist/utils/clone.js
condenser-0.0.7 lib/condenser/processors/node_modules/regexp-tree/dist/utils/clone.js
ezii-os-0.0.0.1.0 node_modules/regexp-tree/dist/utils/clone.js
ezii-os-0.0.0.0.1 node_modules/regexp-tree/dist/utils/clone.js
condenser-0.0.5 lib/condenser/processors/node_modules/regexp-tree/dist/utils/clone.js