File tree 6 files changed +25
-37
lines changed
6 files changed +25
-37
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
2
* .log
3
- .nyc_output /
4
3
coverage /
5
4
node_modules /
6
5
yarn.lock
Original file line number Diff line number Diff line change 1
1
coverage /
2
- * .json
3
2
* .md
Original file line number Diff line number Diff line change 1
- 'use strict'
2
-
3
- module . exports = u
4
-
5
- function u ( type , props , value ) {
1
+ export function u ( type , props , value ) {
6
2
var node = { type : String ( type ) }
7
3
8
- if ( value == null && ( typeof props !== 'object' || Array . isArray ( props ) ) ) {
4
+ if (
5
+ ( value === undefined || value === null ) &&
6
+ ( typeof props !== 'object' || Array . isArray ( props ) )
7
+ ) {
9
8
value = props
10
9
} else {
11
10
Object . assign ( node , props )
12
11
}
13
12
14
13
if ( Array . isArray ( value ) ) {
15
14
node . children = value
16
- } else if ( value != null ) {
15
+ } else if ( value !== undefined && value !== null ) {
17
16
node . value = String ( value )
18
17
}
19
18
Original file line number Diff line number Diff line change 30
30
" Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" ,
31
31
" Christian Murphy <christian.murphy.42@gmail.com>"
32
32
],
33
+ "sideEffects" : false ,
34
+ "type" : " module" ,
35
+ "main" : " index.js" ,
36
+ "types" : " types/index.d.ts" ,
33
37
"files" : [
34
38
" index.js" ,
35
39
" types/index.d.ts"
36
40
],
37
- "types" : " types/index.d.ts" ,
38
41
"devDependencies" : {
39
42
"@types/mdast" : " ^3.0.0" ,
43
+ "c8" : " ^7.0.0" ,
40
44
"dtslint" : " ^4.0.0" ,
41
- "nyc" : " ^15.0.0" ,
42
45
"prettier" : " ^2.0.0" ,
43
46
"remark-cli" : " ^9.0.0" ,
44
47
"remark-preset-wooorm" : " ^8.0.0" ,
47
50
},
48
51
"scripts" : {
49
52
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
50
- "test-api" : " node test" ,
51
- "test-coverage" : " nyc --reporter lcov tape test.js" ,
53
+ "test-api" : " node test.js " ,
54
+ "test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 -- reporter lcov node test.js" ,
52
55
"test-types" : " dtslint types" ,
53
56
"test" : " npm run format && npm run test-coverage && npm run test-types"
54
57
},
55
- "nyc" : {
56
- "check-coverage" : true ,
57
- "lines" : 100 ,
58
- "functions" : 100 ,
59
- "branches" : 100
60
- },
61
58
"prettier" : {
62
59
"tabWidth" : 2 ,
63
60
"useTabs" : false ,
68
65
},
69
66
"xo" : {
70
67
"prettier" : true ,
71
- "esnext" : false ,
72
- "ignore" : [
73
- " types/"
74
- ],
75
68
"rules" : {
76
- "eqeqeq" : [
77
- " error" ,
78
- " always" ,
79
- {
80
- "null" : " ignore"
81
- }
82
- ],
83
- "no-eq-null" : " off"
69
+ "no-var" : " off" ,
70
+ "prefer-arrow-callback" : " off"
84
71
}
85
72
},
86
73
"remarkConfig" : {
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ syntax.
13
13
14
14
## Install
15
15
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
+
16
19
[ npm] [ ] :
17
20
18
21
``` bash
@@ -22,7 +25,7 @@ npm install unist-builder
22
25
## Use
23
26
24
27
``` js
25
- var u = require ( ' unist-builder' )
28
+ import { u } from ' unist-builder'
26
29
27
30
var tree = u (' root' , [
28
31
u (' subtree' , {id: 1 }),
@@ -64,6 +67,9 @@ results in the following tree:
64
67
65
68
## API
66
69
70
+ This package exports the following identifiers: ` u ` .
71
+ There is no default export.
72
+
67
73
### ` u(type[, props][, children|value]) `
68
74
69
75
Creates a node from ` props ` , ` children ` , and optionally ` value ` .
Original file line number Diff line number Diff line change 1
- 'use strict'
1
+ import test from 'tape'
2
+ import { u } from './index.js'
2
3
3
- var test = require ( 'tape' )
4
- var u = require ( '.' )
5
-
6
- test ( function ( t ) {
4
+ test ( 'u' , function ( t ) {
7
5
t . deepEqual (
8
6
u ( 'root' , [
9
7
u ( 'subtree' , { id : 1 } ) ,
You can’t perform that action at this time.
0 commit comments