本文整理汇总了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;未经允许,请勿转载。 |
请发表评论