@putout/plugin-apply-is-array

3.0.2 • Public • Published

@putout/plugin-apply-is-array NPM version

The Array.isArray() method determines whether the passed value is an Array. When checking for Array instance, Array.isArray() is preferred over instanceof because it works through iframes.

(c) MDN

🐊Putout plugin adds ability to apply Array.isArray(). Fits good with @putout/plugin-declare. Merged to @putout/plugin-types.

Install

npm i @putout/plugin-apply-is-array

Rule

{
    "rules": {
        "apply-is-array": "on"
    }
}

Example of incorrect code

x instanceof Array;

Example of correct code

const {isArray} = Array;
isArray(x);

In case of using inline option:

{
    "rules": {
        "apply-is-array": ["on", {
            "inline": true
        }]
    }
}

Array.isArray will be inlined:

Array.isArray(x);

License

MIT

Package Sidebar

Install

npm i @putout/plugin-apply-is-array

Weekly Downloads

1,412

Version

3.0.2

License

MIT

Unpacked Size

4.19 kB

Total Files

4

Last publish

Collaborators

  • coderaiser