本文整理汇总了TypeScript中core/util/typed_array.concat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript concat函数的具体用法?TypeScript concat怎么用?TypeScript concat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了concat函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should concat Float32 arrays", () => {
const a = new Float32Array([1, 2])
const b = new Float32Array([3, 4])
const r = typed_array.concat(a, b)
expect(r).to.be.instanceof(Float32Array)
expect(r).to.be.deep.equal(new Float32Array([1, 2, 3, 4]))
})
示例2: stream_to_column
export function stream_to_column(col: Arrayable, new_col: Arrayable, rollover?: number): Arrayable {
if (isArray(col)) {
const result = col.concat(new_col)
if (rollover != null && result.length > rollover)
return result.slice(-rollover)
else
return result
} else if (isTypedArray(col)) {
const total_len = col.length + new_col.length
// handle rollover case for typed arrays
if (rollover != null && total_len > rollover) {
const start = total_len - rollover
const end = col.length
// resize col if it is shorter than the rollover length
let result: TypedArray
if (col.length < rollover) {
result = new ((col as any).constructor)(rollover)
result.set(col, 0)
} else
result = col
// shift values in original col to accommodate new_col
for (let i = start, endi = end; i < endi; i++) {
result[i-start] = result[i]
}
// update end values in col with new_col
for (let i = 0, endi = new_col.length; i < endi; i++) {
result[i+(end-start)] = new_col[i]
}
return result
} else {
const tmp = new ((col as any).constructor)(new_col)
return typed_array.concat(col, tmp)
}
} else
throw new Error("unsupported array types")
}