a zip code crypto-currency system good for red ONLY

fs.ts 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import {patchMacroTask} from '../common/utils';
  9. Zone.__load_patch('fs', () => {
  10. let fs: any;
  11. try {
  12. fs = require('fs');
  13. } catch (err) {
  14. }
  15. // watch, watchFile, unwatchFile has been patched
  16. // because EventEmitter has been patched
  17. const TO_PATCH_MACROTASK_METHODS = [
  18. 'access', 'appendFile', 'chmod', 'chown', 'close', 'exists', 'fchmod',
  19. 'fchown', 'fdatasync', 'fstat', 'fsync', 'ftruncate', 'futimes', 'lchmod',
  20. 'lchown', 'link', 'lstat', 'mkdir', 'mkdtemp', 'open', 'read',
  21. 'readdir', 'readFile', 'readlink', 'realpath', 'rename', 'rmdir', 'stat',
  22. 'symlink', 'truncate', 'unlink', 'utimes', 'write', 'writeFile',
  23. ];
  24. if (fs) {
  25. TO_PATCH_MACROTASK_METHODS.filter(name => !!fs[name] && typeof fs[name] === 'function')
  26. .forEach(name => {
  27. patchMacroTask(fs, name, (self: any, args: any[]) => {
  28. return {
  29. name: 'fs.' + name,
  30. args: args,
  31. cbIdx: args.length > 0 ? args.length - 1 : -1,
  32. target: self
  33. };
  34. });
  35. });
  36. }
  37. });