當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs.readFileSync類代碼示例

本文整理匯總了TypeScript中fs.readFileSync的典型用法代碼示例。如果您正苦於以下問題:TypeScript readFileSync類的具體用法?TypeScript readFileSync怎麽用?TypeScript readFileSync使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了readFileSync類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: require

 require('fs').readFileSync = function (path, ops) {
   if (path === '/dev/stdin' && ops === 'utf8') {
     require('fs').readFileSync = read;
     return require('fs').readFileSync(input, 'utf8');
   }
   return read.apply(require('fs'), arguments);
 };
開發者ID:falsandtru,項目名稱:algorithm,代碼行數:7,代碼來源:define.test.ts

示例2: function

export default function(
  globalObject: NodeJS.Global,
  globals: Config.ConfigGlobals,
): NodeJS.Global & Config.ConfigGlobals {
  globalObject.process = createProcessObject();

  const symbol = (globalObject.Symbol as unknown) as SymbolConstructor;
  // Keep a reference to some globals that Jest needs
  Object.defineProperties(globalObject, {
    [symbol.for('jest-native-promise')]: {
      enumerable: false,
      value: Promise,
      writable: false,
    },
    [symbol.for('jest-native-now')]: {
      enumerable: false,
      value: globalObject.Date.now.bind(globalObject.Date),
      writable: false,
    },
    [symbol.for('jest-native-read-file')]: {
      enumerable: false,
      value: fs.readFileSync.bind(fs),
      writable: false,
    },
    [symbol.for('jest-native-write-file')]: {
      enumerable: false,
      value: fs.writeFileSync.bind(fs),
      writable: false,
    },
    [symbol.for('jest-native-exists-file')]: {
      enumerable: false,
      value: fs.existsSync.bind(fs),
      writable: false,
    },
    'jest-symbol-do-not-touch': {
      enumerable: false,
      value: symbol,
      writable: false,
    },
  });

  // Forward some APIs.
  DTRACE.forEach(dtrace => {
    // @ts-ignore: no index
    globalObject[dtrace] = function(...args: Array<any>) {
      // @ts-ignore: no index
      return global[dtrace].apply(this, args);
    };
  });

  // Forward some others (this breaks the sandbox but for now it's OK).
  globalObject.Buffer = global.Buffer;
  globalObject.setImmediate = global.setImmediate;
  globalObject.clearImmediate = global.clearImmediate;

  return Object.assign(globalObject, deepCyclicCopy(globals));
}
開發者ID:Volune,項目名稱:jest,代碼行數:57,代碼來源:installCommonGlobals.ts

示例3: it

 it('returns an empty object representation', () => {
   sinon.stub(fs, 'readFileSync').throws();
   expect(loadPackageJson()).to.eql('{}');
   fs.readFileSync.restore();
 });
開發者ID:ThaNarie,項目名稱:tslint-teamcity-reporter,代碼行數:5,代碼來源:index.spec.ts


注:本文中的fs.readFileSync類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。