Skip to content

Commit

Permalink
add support for typed arrays (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack authored Mar 20, 2019
1 parent ff1ea97 commit a52598c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/providers/CanIUseProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,56 @@ const CanIUseProvider: Array<Node> = [
astNodeType: 'MemberExpression',
object: 'performance',
property: 'now'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'TypedArray'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Int8Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Uint8Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Uint8ClampedArray'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Int16Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Uint16Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Int32Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Uint32Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Float32Array'
},
{
caniuseId: 'typedarrays',
astNodeType: 'NewExpression',
object: 'Float64Array'
}
].map(rule =>
Object.assign({}, rule, {
Expand Down
20 changes: 20 additions & 0 deletions test/e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ ruleTester.run('compat', rule, {
}
],
invalid: [
{
code: 'new TypedArray()',
settings: { browsers: ['ie 9'] },
errors: [
{
message: 'TypedArray is not supported in IE 9',
type: 'NewExpression'
}
]
},
{
code: 'new Int8Array()',
settings: { browsers: ['ie 9'] },
errors: [
{
message: 'Int8Array is not supported in IE 9',
type: 'NewExpression'
}
]
},
{
code: 'new AnimationEvent',
settings: { browsers: ['chrome 40'] },
Expand Down

0 comments on commit a52598c

Please sign in to comment.