本文整理汇总了TypeScript中lodash.tail函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tail函数的具体用法?TypeScript tail怎么用?TypeScript tail使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tail函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: cat
function cat(...rest: any[]) {
const head = _.head(rest)
if (existy(head)) {
return Array.prototype.concat.apply(head, _.tail(rest)) // remove apply eg: head.concat.apply(head, _.tail(rest))
}
return []
}
示例2: csv2json
export function csv2json(csv:string): Object[] {
const headers = csv.split('\n')[0].split(',').map(header => {return _.trim(header, '"')});
const lines = _.tail(csv.split('\n'));
return lines.map(line => {
let values = _.map(line.split(','), value => {return _.trim(value, '"')});
values = values.map(value => {return value.length === 0 ? null : value;});
return _.zipObject(headers, values);
});
}
示例3: _compileTemplate
_compileTemplate(template, extension) {
const lines = template.split('\n');
if (extension == '.html') {
lines.unshift('');
}
return {
subject: lines[0],
body: _.tail(lines).join('\n')
};
}
示例4: constructor
constructor(tsv: Array<Array<string>>, public datasetId: string, public filename: string) {
// normalize header-row in tsv-file so that if headers are missing a column
// or identifier is indicated by an empty string
const normalizedHeaders = this.getNormalizeHeaders(tsv);
this.headers = new TSVHeaders(normalizedHeaders);
this.body = new TSVBody(_.tail(tsv));
datasetId;
filename;
}
示例5: insertSeps
function insertSeps(es : t[]) : t {
if (es.length === 0) { return mt() }
else if (es.length === 1) { return es[0] }
else if (es.length === 2) {
const [h, e] = es
return ([] as t[]).concat(h, lastSep, e)
}
else {
const [h, t] = [_.head(es) as t, _.tail(es)]
return ([] as t[]).concat(h, sep, insertSeps(t))
}
}
示例6: f
export function shrinkOne<A>(
f: (a: A) => List<A>,
arr: Array<A>
): List<Array<A>> {
if (arr.length === 0) {
return List.empty<Array<A>>();
}
const x0 = _.head(arr);
const xs0 = _.tail(arr);
const fst = f(x0).map(x1 => [x1].concat(xs0));
const snd = shrinkOne(f, xs0).map(xs1 => [x0].concat(xs1));
return fst.concat(snd);
}
示例7: expect
test.skip("Käännökset lisätty kaikilla kielillä", () => {
const fails = [];
for (const key of _.keys(locales[0][1])) {
for (const locale of _.tail(locales)) {
if (!_.isString(locale[1][key]) || _.isEmpty(locale[1][key])) {
fails.push({
kieli: locale[0],
avain: key,
});
}
}
}
expect(fails.length).toEqual(0);
});
示例8: extractProdBinders
export function extractProdBinders(a : ConstrExprR) : [LocalBinderExpr[], ConstrExprR] {
if (a instanceof CProdN) {
const [bl, c] : [any[], any] = [a.binderList, a.returnExpr]
if (bl.length === 0) {
return extractProdBinders(a.returnExpr)
} else {
const [nal, bk, t] = bl[0]
const [blrec, cRest] = extractProdBinders(new CProdN(_.tail(bl), c))
const l : LocalBinderExpr[] = [new CLocalAssum(nal, bk, t)]
return [l.concat(blrec), cRest]
}
}
return [[], a]
}
示例9: gridRowsFromFile
export function gridRowsFromFile(fileName: string): PrimordialMap {
const rawContents = readFileSync(fileName, 'utf8');
const lines = rawContents.trim().split(GENERAL_LINE_SEPARATOR_REGEXP);
const firstLine = _.head(lines);
const gridRows = _.tail(lines);
const startingPosSplit = firstLine.split(' ');
const row = parseInt(startingPosSplit[ 0 ], 10) - 1;
const col = parseInt(startingPosSplit[ 1 ], 10) - 1;
return {
gridRows,
startingPosition: { row, col }
};
}