-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Typed arrays support #2388
Typed arrays support #2388
Changes from 1 commit
91b03ff
a25ff13
45c2f35
2d81bdc
bcf59d7
bc32981
2372629
909120e
5316c47
0aa0f5e
39ef5a9
36b4e25
40f93f7
d98dcc0
c0e2f73
09d37b6
a7ed2c2
b95e462
53ea0ec
98d2407
01a8443
c15722f
a2fb88b
f0395b5
9b83826
6dd2f69
306986d
d4cb0c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
'use strict'; | ||
|
||
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray; | ||
|
||
/* | ||
* Map an array of x or y coordinates (c) to screen-space pixel coordinates (p). | ||
* The output array is optional, but if provided, it will be reused without | ||
|
@@ -16,7 +18,7 @@ | |
module.exports = function mapArray(out, data, func) { | ||
var i; | ||
|
||
if(!Array.isArray(out)) { | ||
if(!isArrayOrTypedArray(out)) { | ||
// If not an array, make it an array: | ||
out = []; | ||
} else if(out.length > data.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah great. So this is fine, but I guess 🐎 at some point we could make a helper that uses |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
'use strict'; | ||
|
||
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good eyes. Only the inner arrays should be allowed to be typed arrays. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in d4cb0c4 |
||
|
||
/* | ||
* Map an array of x or y coordinates (c) to screen-space pixel coordinates (p). | ||
* The output array is optional, but if provided, it will be reused without | ||
|
@@ -16,7 +18,7 @@ | |
module.exports = function mapArray(out, data, func) { | ||
var i, j; | ||
|
||
if(!Array.isArray(out)) { | ||
if(!isArrayOrTypedArray(out)) { | ||
// If not an array, make it an array: | ||
out = []; | ||
} else if(out.length > data.length) { | ||
|
@@ -26,7 +28,7 @@ module.exports = function mapArray(out, data, func) { | |
} | ||
|
||
for(i = 0; i < data.length; i++) { | ||
if(!Array.isArray(out[i])) { | ||
if(!isArrayOrTypedArray(out[i])) { | ||
// If not an array, make it an array: | ||
out[i] = []; | ||
} else if(out[i].length > data.length) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you go back and forth between this and
isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
- not a big deal but the latter seems marginally preferable to me when you don't need anything else fromLib
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned up in 9b83826