本文整理汇总了TypeScript中util.deprecate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript deprecate函数的具体用法?TypeScript deprecate怎么用?TypeScript deprecate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deprecate函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: bar
/////////////////////////////////////////////////////
/// util tests : https://nodejs.org/api/util.html ///
/////////////////////////////////////////////////////
namespace util_tests {
{
// Old and new util.inspect APIs
util.inspect(["This is nice"], false, 5);
util.inspect(["This is nice"], false, null);
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
util.inspect(["This is nice"], { colors: true, depth: null, customInspect: false });
// util.deprecate
const foo = () => {};
// $ExpectType () => void
util.deprecate(foo, 'foo() is deprecated, use bar() instead');
// $ExpectType <T extends Function>(fn: T, message: string) => T
util.deprecate(util.deprecate, 'deprecate() is deprecated, use bar() instead');
}
}
////////////////////////////////////////////////////
/// Stream tests : http://nodejs.org/api/stream.html
////////////////////////////////////////////////////
// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
function stream_readable_pipe_test() {
var r = fs.createReadStream('file.txt');
var z = zlib.createGzip();
var w = fs.createWriteStream('file.txt.gz');
r.pipe(z).pipe(w);
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:30,代码来源:node-tests.ts
示例2: deprecate
import { map } from 'starry.map'
import { deprecate } from 'util'
export = deprecate(function asyncOperation(operation, iterable, asyncAction) {
return operation(map(iterable, asyncAction))
}, 'Use starry.map instead')
开发者ID:seangenabe,项目名称:starry,代码行数:6,代码来源:index.ts
示例3: convertResult
import { deprecate } from 'util';
import DataEntity, { DataInput } from '../data-entity';
import { isPlainObject, getFirst, castArray, isString } from '../../utils';
/**
* Convert legacy processor results into DataEntities if possible.
* But in order to be more backwards compatible legacy modules
* can return an array of buffers or strings.
*/
export function convertResult(input: DataInput[]|Buffer[]|string[]): DataEntity[] {
if (input == null) return [];
if (Array.isArray(input) && input.length === 0) return [];
if (DataEntity.isDataEntityArray(input)) return input;
if (DataEntity.isDataEntity(input)) return [input];
const first = getFirst<object|string|Buffer>(input);
if (first == null) return [];
// @ts-ignore
if (Array.isArray(first)) return input;
if (Buffer.isBuffer(first) || isString(first)) return deprecateType(input);
if (isPlainObject(first)) return DataEntity.makeArray(input);
throw new Error('Invalid return type for processor');
}
const deprecateType = deprecate((result: any): DataEntity[] => {
return castArray<DataEntity>(result);
}, 'Legacy processors should return an array of Objects or DataEntities');
开发者ID:jeffmontagna,项目名称:teraslice,代码行数:30,代码来源:shim-utils.ts
示例4: deprecate
import dllConf from './config/dll.conf'
import prodConf from './config/prod.conf'
import { appPath } from './util'
import { bindDevLogger, bindProdLogger, bindDllLogger, printBuildError } from './util/logHelper'
import { BuildConfig } from './util/types'
const customizeChain = (chain, config) => {
if (config.webpackChain instanceof Function) {
config.webpackChain(chain, webpack)
}
}
const deprecatedCustomizeConfig = deprecate((baseConfig, customConfig) => {
if (customConfig instanceof Function) {
return customConfig(baseConfig, webpack)
} else if (customConfig instanceof Object) {
return webpackMerge({}, baseConfig, customConfig)
}
}, chalk.yellow(`h5.webpack配置项即将停止支持,请尽快迁移到新配置项。新配置项文档:https://nervjs.github.io/taro/docs/config-detail.html#h5`))
const buildDll = async (config: BuildConfig): Promise<any> => {
if (config.enableDll === false) return Promise.resolve()
return new Promise((resolve, reject) => {
const webpackChain = dllConf(config)
const webpackConfig = webpackChain.toConfig()
const compiler = webpack(webpackConfig)
bindDllLogger(compiler)
compiler.run((err) => {
if (err) {
printBuildError(err)
开发者ID:topud,项目名称:taro,代码行数:31,代码来源:index.ts
示例5: function
}
return this
}
const multi = Pipeline.prototype.multi
Pipeline.prototype.multi = function () {
this._transactions += 1
return multi.apply(this, arguments)
}
const execBuffer = Pipeline.prototype.execBuffer
const exec = Pipeline.prototype.exec
Pipeline.prototype.execBuffer = deprecate(function () {
if (this._transactions > 0) {
this._transactions -= 1
}
return execBuffer.apply(this, arguments)
}, 'Pipeline#execBuffer: Use Pipeline#exec instead')
Pipeline.prototype.exec = function (callback: CallbackFunction) {
if (this._transactions > 0) {
this._transactions -= 1
return (this.options.dropBufferSupport ? exec : execBuffer).apply(this, arguments)
}
if (!this.nodeifiedPromise) {
this.nodeifiedPromise = true
asCallback(this.promise, callback)
}
if (!this._queue.length) {
this.resolve([])
}
开发者ID:luin,项目名称:ioredis,代码行数:32,代码来源:pipeline.ts
注:本文中的util.deprecate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论