Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 28, 2021
1 parent e556e4b commit 5131d07
Show file tree
Hide file tree
Showing 30 changed files with 193 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
strategy:
matrix:
node:
- lts/dubnium
- lts/erbium
- node
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.DS_Store
*.log
.nyc_output/
coverage/
node_modules/
property-information.js
property-information.min.js
yarn.lock
script/react-data.json
script/react-data.js
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
coverage/
property-information.js
property-information.min.js
*.json
*.md
13 changes: 4 additions & 9 deletions find.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
'use strict'

var normalize = require('./normalize')
var DefinedInfo = require('./lib/util/defined-info')
var Info = require('./lib/util/info')
import {normalize} from './normalize.js'
import {DefinedInfo} from './lib/util/defined-info.js'
import {Info} from './lib/util/info.js'

var data = 'data'

module.exports = find

var valid = /^data[-\w.:]+$/i
var dash = /-[a-z]/g
var cap = /[A-Z]/g

function find(schema, value) {
export function find(schema, value) {
var normal = normalize(value)
var prop = value
var Type = Info
Expand Down
19 changes: 19 additions & 0 deletions hast-to-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export var hastToReact = {
classId: 'classID',
dataType: 'datatype',
itemId: 'itemID',
strokeDashArray: 'strokeDasharray',
strokeDashOffset: 'strokeDashoffset',
strokeLineCap: 'strokeLinecap',
strokeLineJoin: 'strokeLinejoin',
strokeMiterLimit: 'strokeMiterlimit',
typeOf: 'typeof',
xLinkActuate: 'xlinkActuate',
xLinkArcRole: 'xlinkArcrole',
xLinkHref: 'xlinkHref',
xLinkRole: 'xlinkRole',
xLinkShow: 'xlinkShow',
xLinkTitle: 'xlinkTitle',
xLinkType: 'xlinkType',
xmlnsXLink: 'xmlnsXlink'
}
19 changes: 0 additions & 19 deletions hast-to-react.json

This file was deleted.

16 changes: 7 additions & 9 deletions html.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict'
import {merge} from './lib/util/merge.js'
import {xlink} from './lib/xlink.js'
import {xml} from './lib/xml.js'
import {xmlns} from './lib/xmlns.js'
import {aria} from './lib/aria.js'
import {html as htmlBase} from './lib/html.js'

var merge = require('./lib/util/merge')
var xlink = require('./lib/xlink')
var xml = require('./lib/xml')
var xmlns = require('./lib/xmlns')
var aria = require('./lib/aria')
var html = require('./lib/html')

module.exports = merge([xml, xlink, xmlns, aria, html])
export var html = merge([xml, xlink, xmlns, aria, htmlBase])
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict'

exports.html = require('./html')
exports.svg = require('./svg')
exports.normalize = require('./normalize')
exports.find = require('./find')
export {html} from './html.js'
export {svg} from './svg.js'
export {normalize} from './normalize.js'
export {find} from './find.js'
12 changes: 3 additions & 9 deletions lib/aria.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
'use strict'
import {booleanish, number, spaceSeparated} from './util/types.js'
import {create} from './util/create.js'

var types = require('./util/types')
var create = require('./util/create')

var booleanish = types.booleanish
var number = types.number
var spaceSeparated = types.spaceSeparated

module.exports = create({
export var aria = create({
transform: ariaTransform,
properties: {
ariaActiveDescendant: null,
Expand Down
24 changes: 11 additions & 13 deletions lib/html.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict'
import {
boolean,
overloadedBoolean,
booleanish,
number,
spaceSeparated,
commaSeparated
} from './util/types.js'
import {create} from './util/create.js'
import {caseInsensitiveTransform} from './util/case-insensitive-transform.js'

var types = require('./util/types')
var create = require('./util/create')
var caseInsensitiveTransform = require('./util/case-insensitive-transform')

var boolean = types.boolean
var overloadedBoolean = types.overloadedBoolean
var booleanish = types.booleanish
var number = types.number
var spaceSeparated = types.spaceSeparated
var commaSeparated = types.commaSeparated

module.exports = create({
export var html = create({
space: 'html',
attributes: {
acceptcharset: 'accept-charset',
Expand Down
22 changes: 10 additions & 12 deletions lib/svg.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict'
import {
boolean,
number,
spaceSeparated,
commaSeparated,
commaOrSpaceSeparated
} from './util/types.js'
import {create} from './util/create.js'
import {caseSensitiveTransform} from './util/case-sensitive-transform.js'

var types = require('./util/types')
var create = require('./util/create')
var caseSensitiveTransform = require('./util/case-sensitive-transform')

var boolean = types.boolean
var number = types.number
var spaceSeparated = types.spaceSeparated
var commaSeparated = types.commaSeparated
var commaOrSpaceSeparated = types.commaOrSpaceSeparated

module.exports = create({
export var svg = create({
space: 'svg',
attributes: {
accentHeight: 'accent-height',
Expand Down
8 changes: 2 additions & 6 deletions lib/util/case-insensitive-transform.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
'use strict'
import {caseSensitiveTransform} from './case-sensitive-transform.js'

var caseSensitiveTransform = require('./case-sensitive-transform')

module.exports = caseInsensitiveTransform

function caseInsensitiveTransform(attributes, property) {
export function caseInsensitiveTransform(attributes, property) {
return caseSensitiveTransform(attributes, property.toLowerCase())
}
6 changes: 1 addition & 5 deletions lib/util/case-sensitive-transform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'use strict'

module.exports = caseSensitiveTransform

function caseSensitiveTransform(attributes, attribute) {
export function caseSensitiveTransform(attributes, attribute) {
return attribute in attributes ? attributes[attribute] : attribute
}
12 changes: 4 additions & 8 deletions lib/util/create.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use strict'
import {normalize} from '../../normalize.js'
import {Schema} from './schema.js'
import {DefinedInfo} from './defined-info.js'

var normalize = require('../../normalize')
var Schema = require('./schema')
var DefinedInfo = require('./defined-info')

module.exports = create

function create(definition) {
export function create(definition) {
var property = {}
var normal = {}
var prop
Expand Down
8 changes: 3 additions & 5 deletions lib/util/defined-info.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'
import {Info} from './info.js'
import * as types from './types.js'

var Info = require('./info')
var types = require('./types')

module.exports = DefinedInfo
export {DefinedInfo}

DefinedInfo.prototype = new Info()
DefinedInfo.prototype.defined = true
Expand Down
4 changes: 1 addition & 3 deletions lib/util/info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict'

module.exports = Info
export {Info}

var proto = Info.prototype

Expand Down
10 changes: 3 additions & 7 deletions lib/util/merge.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict'
import xtend from 'xtend'
import {Schema} from './schema.js'

var xtend = require('xtend')
var Schema = require('./schema')

module.exports = merge

function merge(definitions) {
export function merge(definitions) {
var property = []
var normal = []
var index = -1
Expand Down
4 changes: 1 addition & 3 deletions lib/util/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict'

module.exports = Schema
export {Schema}

var proto = Schema.prototype

Expand Down
16 changes: 7 additions & 9 deletions lib/util/types.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'

var powers = 0

exports.boolean = increment()
exports.booleanish = increment()
exports.overloadedBoolean = increment()
exports.number = increment()
exports.spaceSeparated = increment()
exports.commaSeparated = increment()
exports.commaOrSpaceSeparated = increment()
export var boolean = increment()
export var booleanish = increment()
export var overloadedBoolean = increment()
export var number = increment()
export var spaceSeparated = increment()
export var commaSeparated = increment()
export var commaOrSpaceSeparated = increment()

function increment() {
return Math.pow(2, ++powers)
Expand Down
6 changes: 2 additions & 4 deletions lib/xlink.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {create} from './util/create.js'

var create = require('./util/create')

module.exports = create({
export var xlink = create({
space: 'xlink',
transform: xlinkTransform,
properties: {
Expand Down
6 changes: 2 additions & 4 deletions lib/xml.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {create} from './util/create.js'

var create = require('./util/create')

module.exports = create({
export var xml = create({
space: 'xml',
transform: xmlTransform,
properties: {
Expand Down
8 changes: 3 additions & 5 deletions lib/xmlns.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'
import {create} from './util/create.js'
import {caseInsensitiveTransform} from './util/case-insensitive-transform.js'

var create = require('./util/create')
var caseInsensitiveTransform = require('./util/case-insensitive-transform')

module.exports = create({
export var xmlns = create({
space: 'xmlns',
attributes: {
xmlnsxlink: 'xmlns:xlink'
Expand Down
6 changes: 1 addition & 5 deletions normalize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'use strict'

module.exports = normalize

function normalize(value) {
export function normalize(value) {
return value.toLowerCase()
}
Loading

0 comments on commit 5131d07

Please sign in to comment.