source: trip-planner-front/node_modules/graceful-fs/clone.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 496 bytes
Line 
1'use strict'
2
3module.exports = clone
4
5var getPrototypeOf = Object.getPrototypeOf || function (obj) {
6 return obj.__proto__
7}
8
9function clone (obj) {
10 if (obj === null || typeof obj !== 'object')
11 return obj
12
13 if (obj instanceof Object)
14 var copy = { __proto__: getPrototypeOf(obj) }
15 else
16 var copy = Object.create(null)
17
18 Object.getOwnPropertyNames(obj).forEach(function (key) {
19 Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
20 })
21
22 return copy
23}
Note: See TracBrowser for help on using the repository browser.