本文整理汇总了TypeScript中lodash.trimStart函数的典型用法代码示例。如果您正苦于以下问题:TypeScript trimStart函数的具体用法?TypeScript trimStart怎么用?TypeScript trimStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trimStart函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
router.post('/save', async (req: any, res) => {
if (req.query.type === 'file') {
if (req.query.filename === '') {
res.send({});
return;
}
if (req.query.filename === '.json') {
res.send({});
return;
}
await fileManager.saveFile(
req.user.id,
`${trimStart(req.query.dirname, '/')}/${req.query.filename}`,
req.body.content,
);
} else {
await fileManager.createDir(
req.user.id,
`${trimStart(req.query.dirname, '/')}/${req.query.filename}`,
);
}
res.send({});
});
开发者ID:pierophp,项目名称:pinyin,代码行数:26,代码来源:files.controller.ts
示例2: map
map(lines => {
const codeElement = singleFileDOMFunctions.getCodeElementFromLineNumber(
codeView,
position.line,
position.part
)
if (!codeElement) {
throw new Error('(adjustPosition) could not find code element for line provided')
}
const actualLine = lines[position.line - 1]
const documentLine = codeElement.textContent || ''
const actualLeadingWhiteSpace = actualLine.length - trimStart(actualLine).length
const documentLeadingWhiteSpace = documentLine.length - trimStart(documentLine).length
const modifier = direction === AdjustmentDirection.ActualToCodeView ? -1 : 1
const delta = Math.abs(actualLeadingWhiteSpace - documentLeadingWhiteSpace) * modifier
return {
line: position.line,
character: position.character + delta,
}
})
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:24,代码来源:code_intelligence.ts
示例3: trimStart
import {trim, trimStart, trimEnd, pad, padStart, padEnd} from "lodash";
const trimStr: string = " trim ";
console.log("trimStart()");
console.log("*" + trimStart(trimStr) + "*");
console.log("trimEnd()");
console.log("*" + trimEnd(trimStr) + "*");
console.log("trim()");
console.log("*" + trim(trimStr) + "*");
const padStr: string = "pad";
console.log("padStart()");
console.log(padStart(padStr, 10, "_"));
console.log("padEnd()");
console.log(padEnd(padStr, 10, "_"));
console.log("pad()");
console.log(pad(padStr, 10, "_"));
开发者ID:kwpeters,项目名称:node-sandbox,代码行数:18,代码来源:lodashTest.ts
示例4: checkForLeadingWhitespace
function checkForLeadingWhitespace(filePath: string, fileContents: string) {
const fileHasLeadingWhitespace = trimStart(fileContents).length !== fileContents.length;
const failures: Failure[] = fileHasLeadingWhitespace ? [{ filePath, message: 'File has leading whitespace.' }] : [];
return failures;
}
开发者ID:kevinphelps,项目名称:kevinphelps.me,代码行数:5,代码来源:prelint.ts
示例5: Promise
return new Promise((resolve, reject) => {
let params;
const startTime = new Date().getTime();
if (_.isEmpty(_self._config.target)) {
return reject(new errors.TargetError(opts, 'Target not set'));
}
// Validate Opts
_.forEach(_.pick(opts, ['startElement', 'numElements']), (value, opt) => {
if (_hasValue(value) && !_isInteger(value)) {
return reject(new errors.ArgumentError(opts, 'Invalid ' + opt));
}
return null;
});
// Configure Options
let reqOpts: IRequestOptionsInternal = {
method: (opts.method || Method.GET).toUpperCase(),
uri: urlJoin(_self._config.target, _.trimStart(opts.uri, '/')),
timeout: opts.timeout || _self._config.timeout,
rejectUnauthorized: false,
headers: { ..._self._config.headers },
params: { ...opts.params },
body: opts.body,
encodeParams: _.get(opts, 'encodeParams', false),
};
if (_self._config.userAgent) {
reqOpts.headers['User-Agent'] = _self._config.userAgent;
}
if (!opts.noAuth && !opts.auth && _self._config.token) {
reqOpts.headers.Authorization = _self._config.token;
}
if (opts.mimeType) {
reqOpts.headers.Accept = opts.mimeType;
if (opts.method === Method.POST || opts.method === Method.PUT) {
reqOpts.headers['Content-Type'] = opts.mimeType;
}
} else {
// Default Accept to application/json
reqOpts.headers.Accept = _.get(opts, 'headers.Accept', 'application/json');
// Default Content-Type to application/json for POSTs and PUTs
if (reqOpts.method === Method.POST || reqOpts.method === Method.PUT) {
reqOpts.headers['Content-Type'] = _.get(opts, 'headers.Content-Type', 'application/json');
}
}
reqOpts.headers = _.assign({}, reqOpts.headers, opts.headers);
// Configure Parameters
if (_hasValue(opts.startElement)) {
reqOpts.params.start_element = (+opts.startElement).toString();
}
if (_hasValue(opts.numElements)) {
reqOpts.params.num_elements = (+opts.numElements).toString();
reqOpts.params.start_element = (+opts.startElement || reqOpts.params.start_element || 0).toString(); // startElement is required if numElements is set
}
params = query.stringify(reqOpts.params, {encode: reqOpts.encodeParams});
if (params !== '') {
reqOpts.uri += (opts.uri.indexOf('?') === -1) ? '?' : '&';
reqOpts.uri += params;
}
if (_self._config.beforeRequest) {
const beforeRequestOpts = _self._config.beforeRequest(reqOpts);
if (beforeRequestOpts) {
reqOpts = _.assign({}, reqOpts, beforeRequestOpts);
}
}
return _self._config.request(reqOpts).then((res) => {
const totalTime = new Date().getTime() - startTime;
let newRes: IResponse = _.assign({
requestTime: res.requestTime || totalTime,
totalTime: new Date().getTime() - startTime,
}, res);
if (_self._config.afterRequest) {
const afterRequestRes = _self._config.afterRequest(newRes);
if (afterRequestRes) {
newRes = _.assign({}, newRes, afterRequestRes);
}
}
if (newRes.statusCode >= 400) {
return reject(errors.buildError(reqOpts, newRes));
}
// Temporary fix
let errorId;
let errorCode;
if (newRes.body && newRes.body.response && newRes.body.response) {
errorId = newRes.body.response.error_id;
//.........这里部分代码省略.........
开发者ID:appnexus,项目名称:anx-api,代码行数:101,代码来源:api.ts
注:本文中的lodash.trimStart函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论