Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 26, 2021
1 parent 697c083 commit 775b154
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 36 deletions.
3 changes: 0 additions & 3 deletions .gitignore
@@ -1,8 +1,5 @@
.DS_Store
*.log
.nyc_output/
coverage/
node_modules/
hast-util-whitespace.js
hast-util-whitespace.min.js
yarn.lock
3 changes: 0 additions & 3 deletions .prettierignore
@@ -1,5 +1,2 @@
coverage/
hast-util-whitespace.js
hast-util-whitespace.min.js
*.json
*.md
6 changes: 1 addition & 5 deletions index.js
@@ -1,8 +1,4 @@
'use strict'

module.exports = interElementWhiteSpace

function interElementWhiteSpace(node) {
export function whitespace(node) {
var value =
node && typeof node === 'object' && node.type === 'text'
? node.value || ''
Expand Down
32 changes: 12 additions & 20 deletions package.json
Expand Up @@ -26,27 +26,25 @@
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js"
],
"devDependencies": {
"browserify": "^17.0.0",
"nyc": "^15.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.38.0"
"xo": "^0.39.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build-bundle": "browserify . -s hastUtilWhitespace -o hast-util-whitespace.js",
"build-mangle": "browserify . -s hastUtilWhitespace -o hast-util-whitespace.min.js -p tinyify",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
Expand All @@ -58,16 +56,10 @@
},
"xo": {
"prettier": true,
"esnext": false,
"ignores": [
"hast-util-whitespace.js"
]
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
},
"remarkConfig": {
"plugins": [
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Expand Up @@ -13,6 +13,9 @@ whitespace*][spec].

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.

[npm][]:

```sh
Expand All @@ -22,7 +25,7 @@ npm install hast-util-whitespace
## Use

```js
var whitespace = require('hast-util-whitespace')
import {whitespace} from 'hast-util-whitespace'

whitespace({
type: 'element',
Expand All @@ -43,6 +46,9 @@ whitespace({

## API

This package exports the following identifiers: `whitespace`.
There is no default export.

### `whitespace(node|value)`

Check if the given value is [*inter-element whitespace*][spec].
Expand Down
6 changes: 2 additions & 4 deletions test.js
@@ -1,7 +1,5 @@
'use strict'

var test = require('tape')
var whitespace = require('.')
import test from 'tape'
import {whitespace} from './index.js'

test('whitespace', function (t) {
t.equal(whitespace(), false, 'should return `false` without node')
Expand Down

0 comments on commit 775b154

Please sign in to comment.