Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 24, 2020
1 parent 720aa57 commit cfddfaf
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage/
*.json
*.md
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var endpoint =
'https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/supplementalMetadata.xml'

fetch(endpoint)
.then(res => res.text())
.then((response) => response.text())
.then(onbody, console.error)

function onbody(doc) {
Expand Down
35 changes: 18 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ var stringify = bcp47.stringify
var collator = new Intl.Collator()

function normalize(value, options) {
var opts = options || {}
var forgiving = opts.forgiving
var warning = opts.warning
var settings = options || {}
var forgiving = settings.forgiving
var warning = settings.warning
// 1. normalize and lowercase the tag (`sgn-be-fr` -> `sfb`).
var schema = parse(String(value || '').toLowerCase(), {forgiving, warning})
var tag = stringify(schema)
Expand Down Expand Up @@ -135,30 +135,31 @@ function replace(schema, from, to) {
}
}

function remove(obj, key, value) {
function remove(object, key, value) {
var removed = false
var current
var result
var length
var index
var val
var item

/* istanbul ignore else - this is currently done by wrapping code, so else is
* never reached.
* However, that could change in the future, so leave this guard here. */
if (value) {
current = obj[key]
current = object[key]
result = current

if (array(current)) {
result = []
length = current.length
index = -1

while (++index < length) {
val = current[index]
item = current[index]

if (value.indexOf(val) === -1) {
result.push(val)
if (value.indexOf(item) === -1) {
result.push(item)
} else {
removed = true
}
Expand All @@ -168,35 +169,35 @@ function remove(obj, key, value) {
removed = true
}

obj[key] = result
object[key] = result
}

return removed
}

function add(obj, key, value) {
var current = obj[key]
function add(object, key, value) {
var current = object[key]
var list
var length
var index
var val
var item

if (array(current)) {
list = [].concat(value)
length = list.length
index = -1

while (++index < length) {
val = list[index]
item = list[index]

/* istanbul ignore else - this currently can’t happen, but guard for the
* future. */
if (current.indexOf(val) === -1) {
current.push(val)
if (current.indexOf(item) === -1) {
current.push(item)
}
}
} else {
obj[key] = value
object[key] = value
}
}

Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
"devDependencies": {
"node-fetch": "^2.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"prettier": "^2.0.0",
"remark-cli": "^8.0.0",
"remark-preset-wooorm": "^7.0.0",
"tape": "^5.0.0",
"unist-util-visit": "^2.0.0",
"xast-util-from-xml": "^1.0.0",
"xo": "^0.26.0"
"xo": "^0.32.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"format": "remark . -qfo && prettier --write . && xo --fix",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run test-coverage"
Expand All @@ -65,7 +65,9 @@
"prettier": true,
"esnext": false,
"rules": {
"unicorn/prefer-includes": "off"
"unicorn/prefer-includes": "off",
"unicorn/prefer-number-properties": "off",
"unicorn/prefer-set-has": "off"
}
},
"nyc": {
Expand Down
16 changes: 8 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
var test = require('tape')
var normalize = require('.')

test('bcp-47-normalize', function(t) {
t.test('basic', function(t) {
test('bcp-47-normalize', function (t) {
t.test('basic', function (t) {
t.equal(normalize(), '', 'should not fail on without a value')
t.equal(normalize(''), '', 'should not fail on an empty string')
t.equal(normalize('en-us'), 'en', 'should normalize')
Expand All @@ -22,7 +22,7 @@ test('bcp-47-normalize', function(t) {
'should ignore trailing stuff in forgiving mode'
)

t.test('should emit when given a warning function', function(t) {
t.test('should emit when given a warning function', function (t) {
t.plan(1)

normalize('en-aaa-bbb-ccc-ddd', {warning: warning})
Expand All @@ -40,7 +40,7 @@ test('bcp-47-normalize', function(t) {
}
})

t.test('should emit if deprecated tags can’t be fixed', function(t) {
t.test('should emit if deprecated tags can’t be fixed', function (t) {
t.plan(1)

normalize('pap-an', {warning: warning})
Expand All @@ -54,7 +54,7 @@ test('bcp-47-normalize', function(t) {
}
})

t.test('should not emit if there are no deprecated tags', function(t) {
t.test('should not emit if there are no deprecated tags', function (t) {
var called = false

t.plan(1)
Expand All @@ -71,7 +71,7 @@ test('bcp-47-normalize', function(t) {
t.end()
})

t.test('normalize', function(t) {
t.test('normalize', function (t) {
t.equal(
normalize('art-lojban'),
'jbo',
Expand Down Expand Up @@ -168,7 +168,7 @@ test('bcp-47-normalize', function(t) {
t.end()
})

t.test('fixtures', function(t) {
t.test('fixtures', function (t) {
var fixtures = {
afb: 'afb',
'ar-afb': 'ar-afb',
Expand Down Expand Up @@ -256,7 +256,7 @@ test('bcp-47-normalize', function(t) {
'zh-yue': 'zh-yue'
}

Object.keys(fixtures).forEach(from => {
Object.keys(fixtures).forEach((from) => {
var to = fixtures[from]
t.equal(normalize(from), to, '`' + from + '` -> `' + to + '`')
})
Expand Down

0 comments on commit cfddfaf

Please sign in to comment.