Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return typed arrays as lists #10204

Merged
merged 1 commit into from
Jun 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions bokehjs/src/lib/core/has_props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Property} from "./properties"
import {uniqueId} from "./util/string"
import {max, copy} from "./util/array"
import {entries, clone, extend, isEmpty} from "./util/object"
import {isPlainObject, isObject, isArray, isString, isFunction} from "./util/types"
import {isPlainObject, isObject, isArray, isTypedArray, isString, isFunction} from "./util/types"
import {isEqual} from './util/eq'
import {ColumnarDataSource} from "models/sources/columnar_data_source"
import {Document, DocumentEvent, DocumentEventBatch, ModelChangedEvent} from "../document"
Expand Down Expand Up @@ -435,11 +435,12 @@ export abstract class HasProps extends Signalable() {
return value.ref()
else if (is_NDArray(value))
return encode_NDArray(value)
else if (isArray(value)) {
const ref_array: unknown[] = []
for (let i = 0; i < value.length; i++) {
else if (isArray(value) || isTypedArray(value)) {
const n = value.length
const ref_array: unknown[] = new Array(n)
for (let i = 0; i < n; i++) {
const v = value[i]
ref_array.push(HasProps._value_to_json(v))
ref_array[i] = HasProps._value_to_json(v)
}
return ref_array
} else if (isPlainObject(value)) {
Expand Down
2 changes: 1 addition & 1 deletion bokehjs/src/lib/core/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function isArrayableOf<T>(arr: Arrayable, predicate: (item: unknown) => i
}

export function isTypedArray(obj: unknown): obj is TypedArray {
return obj != null && (obj as any).buffer instanceof ArrayBuffer
return ArrayBuffer.isView(obj) && !(obj instanceof DataView)
}

export function isObject(obj: unknown): obj is object {
Expand Down