Skip to content

Commit

Permalink
Remove x-is-array dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 31, 2021
1 parent f945aef commit f7812a9
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 28 deletions.
3 changes: 1 addition & 2 deletions packages/rehype-minify-attribute-whitespace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Note: Don’t include non-strings (such as `boolean`s) here, they’re already
// handled in the generator.

import array from 'x-is-array'
import visit from 'unist-util-visit'
import has from 'hast-util-has-property'
import is from 'hast-util-is-element'
Expand Down Expand Up @@ -41,7 +40,7 @@ function visitor(node) {
}

function minify(value) {
return (array(value) ? all : one)(value)
return (Array.isArray(value) ? all : one)(value)
}

function all(value) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-minify-attribute-whitespace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"hast-util-has-property": "^1.0.0",
"hast-util-is-element": "^1.0.0",
"hast-util-is-event-handler": "^1.0.0",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-minify-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/

import Relate from 'relateurl'
import array from 'x-is-array'
import visit from 'unist-util-visit'
import has from 'hast-util-has-property'
import is from 'hast-util-is-element'
Expand Down Expand Up @@ -54,7 +53,7 @@ export default function rehypeMinifyUrl(options) {
}

function minify(value, relate) {
return (array(value) ? all : one)(value, relate)
return (Array.isArray(value) ? all : one)(value, relate)
}

function all(value, relate) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-minify-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"hast-util-is-element": "^1.0.0",
"html-url-attributes": "^1.0.0",
"relateurl": "^0.2.7",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-normalize-attribute-value-case/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* <form method="GET"></form>
*/

import array from 'x-is-array'
import visit from 'unist-util-visit'
import has from 'hast-util-has-property'
import is from 'hast-util-is-element'
Expand Down Expand Up @@ -35,7 +34,7 @@ function visitor(node) {
}

function minify(value) {
return (array(value) ? all : one)(value)
return (Array.isArray(value) ? all : one)(value)
}

function all(value) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-normalize-attribute-value-case/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"dependencies": {
"hast-util-has-property": "^1.0.0",
"hast-util-is-element": "^1.0.0",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-prevent-favicon-request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* <!doctype html><html><head></head><body></body></html>
*/

import array from 'x-is-array'
import visit from 'unist-util-visit'

export default function rehypePreventFaviconRequest() {
Expand Down Expand Up @@ -49,7 +48,7 @@ function transform(tree) {
rel = node.properties.rel

if (
array(rel) &&
Array.isArray(rel) &&
rel.indexOf('shortcut') !== -1 &&
rel.indexOf('icon') !== -1
) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-prevent-favicon-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"index.js"
],
"dependencies": {
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
7 changes: 5 additions & 2 deletions packages/rehype-remove-duplicate-attribute-values/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import uniq from 'uniq'
import array from 'x-is-array'
import visit from 'unist-util-visit'
import is from 'hast-util-is-element'
import {schema} from './schema.js'
Expand All @@ -29,7 +28,11 @@ function visitor(node) {
for (prop in props) {
value = props[prop]

if (own.call(schema, prop) && is(node, schema[prop]) && array(value)) {
if (
own.call(schema, prop) &&
is(node, schema[prop]) &&
Array.isArray(value)
) {
uniq(value)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"dependencies": {
"hast-util-is-element": "^1.0.0",
"uniq": "^1.0.1",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-remove-empty-attribute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* <label for id=""></label>
*/

import array from 'x-is-array'
import visit from 'unist-util-visit'
import is from 'hast-util-is-element'
import {isEventHandler} from 'hast-util-is-event-handler'
Expand All @@ -30,7 +29,7 @@ function visitor(node) {
value = props[prop]

if (
(value === '' || (array(value) && value.length === 0)) &&
(value === '' || (Array.isArray(value) && value.length === 0)) &&
(isEventHandler(prop) ||
(own.call(schema, prop) && is(node, schema[prop])))
) {
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-remove-empty-attribute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"dependencies": {
"hast-util-is-element": "^1.0.0",
"hast-util-is-event-handler": "^1.0.0",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
7 changes: 5 additions & 2 deletions packages/rehype-sort-attribute-values/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* <div class="qux quux foo bar"></div>
*/

import array from 'x-is-array'
import visit from 'unist-util-visit'
import is from 'hast-util-is-element'
import {schema} from './schema.js'
Expand All @@ -34,7 +33,11 @@ function transform(tree) {
for (prop in props) {
value = props[prop]

if (own.call(schema, prop) && is(node, schema[prop]) && array(value)) {
if (
own.call(schema, prop) &&
is(node, schema[prop]) &&
Array.isArray(value)
) {
add(prop, value)
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-sort-attribute-values/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
],
"dependencies": {
"hast-util-is-element": "^1.0.0",
"unist-util-visit": "^2.0.0",
"x-is-array": "^0.1.0"
"unist-util-visit": "^2.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down

0 comments on commit f7812a9

Please sign in to comment.