本文整理匯總了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")
}