説明なし

fs.js 429B

123456789101112131415161718192021
  1. 'use strict'
  2. var fs = require('fs')
  3. module.exports = clone(fs)
  4. function clone (obj) {
  5. if (obj === null || typeof obj !== 'object')
  6. return obj
  7. if (obj instanceof Object)
  8. var copy = { __proto__: obj.__proto__ }
  9. else
  10. var copy = Object.create(null)
  11. Object.getOwnPropertyNames(obj).forEach(function (key) {
  12. Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
  13. })
  14. return copy
  15. }