Skip to content

Commit b49e25c

Browse files
committed
Use ESM
1 parent e5b4367 commit b49e25c

File tree

6 files changed

+25
-39
lines changed

6 files changed

+25
-39
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
.DS_Store
22
*.log
3-
.nyc_output/
43
coverage/
54
node_modules/
6-
hast-util-has-property.js
7-
hast-util-has-property.min.js
85
yarn.lock

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
coverage/
2-
hast-util-has-property.js
3-
hast-util-has-property.min.js
4-
*.json
52
*.md

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
'use strict'
2-
31
var own = {}.hasOwnProperty
42

5-
module.exports = hasProperty
6-
73
// Check if `node` has a set `name` property.
8-
function hasProperty(node, name) {
4+
export function hasProperty(node, name) {
95
var value =
106
node &&
117
node.type === 'element' &&

package.json

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,25 @@
2424
"contributors": [
2525
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
2626
],
27+
"sideEffects": false,
28+
"type": "module",
29+
"main": "index.js",
2730
"files": [
2831
"index.js"
2932
],
3033
"devDependencies": {
31-
"browserify": "^17.0.0",
32-
"nyc": "^15.0.0",
34+
"c8": "^7.0.0",
3335
"prettier": "^2.0.0",
3436
"remark-cli": "^9.0.0",
3537
"remark-preset-wooorm": "^8.0.0",
3638
"tape": "^5.0.0",
37-
"tinyify": "^3.0.0",
38-
"xo": "^0.38.0"
39+
"xo": "^0.39.0"
3940
},
4041
"scripts": {
4142
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
42-
"build-bundle": "browserify . -s hastUtilHasProperty -o hast-util-has-property.js",
43-
"build-mangle": "browserify . -s hastUtilHasProperty -o hast-util-has-property.min.js -p tinyify",
44-
"build": "npm run build-bundle && npm run build-mangle",
45-
"test-api": "node test",
46-
"test-coverage": "nyc --reporter lcov tape test.js",
47-
"test": "npm run format && npm run build && npm run test-coverage"
43+
"test-api": "node test.js",
44+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
45+
"test": "npm run format && npm run test-coverage"
4846
},
4947
"prettier": {
5048
"tabWidth": 2,
@@ -56,16 +54,10 @@
5654
},
5755
"xo": {
5856
"prettier": true,
59-
"esnext": false,
60-
"ignores": [
61-
"hast-util-has-property.js"
62-
]
63-
},
64-
"nyc": {
65-
"check-coverage": true,
66-
"lines": 100,
67-
"functions": 100,
68-
"branches": 100
57+
"rules": {
58+
"no-var": "off",
59+
"prefer-arrow-callback": "off"
60+
}
6961
},
7062
"remarkConfig": {
7163
"plugins": [

readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
## Install
1515

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

1821
```sh
@@ -22,11 +25,11 @@ npm install hast-util-has-property
2225
## Use
2326

2427
```js
25-
var has = require('hast-util-has-property')
28+
import {hasProperty} from 'hast-util-has-property'
2629

27-
has({type: 'text', value: 'alpha'}, 'bravo') // => false
30+
hasProperty({type: 'text', value: 'alpha'}, 'bravo') // => false
2831

29-
has(
32+
hasProperty(
3033
{
3134
type: 'element',
3235
tagName: 'div',
@@ -36,7 +39,7 @@ has(
3639
'className'
3740
) // => false
3841

39-
has(
42+
hasProperty(
4043
{
4144
type: 'element',
4245
tagName: 'div',
@@ -49,6 +52,9 @@ has(
4952

5053
## API
5154

55+
This package exports the following identifiers: `hasProperty`.
56+
There is no default export.
57+
5258
### `hasProperty(node, name)`
5359

5460
Check if `node` is an [*element*][element] that has a `name`

test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var hasProperty = require('.')
1+
import test from 'tape'
2+
import {hasProperty} from './index.js'
53

64
test('hasProperty', function (t) {
75
t.equal(

0 commit comments

Comments
 (0)