-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this diff I migrated the project to esm and provided module field which is useful for bundlers. My usecase is rollup. It is able to handle only esm. And this package requires me to add commonjs and json plugins. As a side bonus this module can be used in browsers without bundlers similar to this https://unpkg.com/jss@next?module. For `tap` I wasn't able to setup esm so I replaced it with `tape`.
- Loading branch information
Showing
13 changed files
with
85 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ node_modules | |
package-lock.json | ||
.nyc_output | ||
coverage | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import json from 'rollup-plugin-json' | ||
import pkg from './package.json' | ||
|
||
export default [ | ||
{ | ||
input: './country-list.js', | ||
output: { file: pkg.main, format: 'cjs' }, | ||
plugins: [json()] | ||
}, | ||
{ | ||
input: './country-list.js', | ||
output: { file: pkg.module, format: 'esm' }, | ||
plugins: [json()] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
'use strict' | ||
|
||
var { test } = require('tap') | ||
var { getCode } = require('../') | ||
import { test } from 'tape' | ||
import { getCode } from '../country-list.js' | ||
|
||
test('get code from country name', function (t) { | ||
t.equal(getCode('Iceland'), 'IS', 'name "Iceland" should return IS') | ||
t.equal(getCode('iceland'), 'IS', 'name "iceland" should return IS') | ||
t.equal(getCode('ICELAND'), 'IS', 'name "ICELAND" should return IS') | ||
t.type(getCode('Iceland'), 'string', 'type of name "Iceland" is string') | ||
t.type(getCode('IS'), 'undefined', 'type of name "IS" is undefined') | ||
t.type(getCode('FarFarAwayLand'), 'undefined', 'name "FarFarAwayLand" should return undefined') | ||
t.type(getCode(''), 'undefined', 'empty name should return undefined') | ||
t.equal(countries.getCode('Iceland'), 'IS', 'name "Iceland" should return IS') | ||
t.equal(countries.getCode('iceland'), 'IS', 'name "iceland" should return IS') | ||
t.equal(countries.getCode('ICELAND'), 'IS', 'name "ICELAND" should return IS') | ||
t.equal(typeof countries.getCode('Iceland'), 'string', 'type of name "Iceland" is string') | ||
t.equal(typeof countries.getCode('IS'), 'undefined', 'type of name "IS" is undefined') | ||
t.equal(typeof countries.getCode('FarFarAwayLand'), 'undefined', 'name "FarFarAwayLand" should return undefined') | ||
t.equal(typeof countries.getCode(''), 'undefined', 'empty name should return undefined') | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
'use strict' | ||
|
||
var { test } = require('tap') | ||
var { getCodes } = require('../') | ||
var data = require('../data.json') | ||
import { test } from 'tape' | ||
import { getCodes } from '../country-list.js' | ||
import data from '../data.json' | ||
|
||
test('get all country codes', function (t) { | ||
t.equal(getCodes().length, data.length, 'codes should be as many as countries') | ||
t.ok(getCodes().indexOf('IS') > -1, 'codes should include IS') | ||
t.ok(getCodes().indexOf('is') === -1, 'codes is case-sensitive, does not include is') | ||
t.type(getCodes(), Array, 'code list is an array') | ||
t.equal(countries.getCodes().length, data.length, 'codes should be as many as countries') | ||
t.ok(countries.getCodes().indexOf('IS') > -1, 'codes should include IS') | ||
t.ok(countries.getCodes().indexOf('is') === -1, 'codes is case-sensitive, does not include is') | ||
t.ok(countries.getCodes() instanceof Array, 'code list is an array') | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
'use strict' | ||
|
||
var { test } = require('tap') | ||
var { getData } = require('../') | ||
var data = require('../data.json') | ||
import { test } from 'tape' | ||
import { getData } from '../country-list.js' | ||
import data from '../data.json' | ||
|
||
test('get all country names', function (t) { | ||
t.equal(getData().length, data.length, 'data list should be the same lenght as data.json') | ||
t.type(getData(), Array, 'data list is an array') | ||
t.type(getData()[0], Object, 'first item in list should be object') | ||
t.equal(countries.getData().length, data.length, 'data list should be the same lenght as data.json') | ||
t.ok(countries.getData() instanceof Array, 'data list is an array') | ||
t.ok(countries.getData()[0] instanceof Object, 'first item in list should be object') | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
'use strict' | ||
|
||
var { test } = require('tap') | ||
var { getName } = require('../') | ||
import { test } from 'tape' | ||
import { getName } from '../country-list.js' | ||
|
||
test('get name from country code', function (t) { | ||
t.equal(getName('IS'), 'Iceland', 'code "IS" should return Iceland') | ||
t.equal(getName('is'), 'Iceland', 'code "is" should return Iceland') | ||
t.type(getName('IS'), 'string', 'type of code "IS" is string') | ||
t.type(getName('Iceland'), 'undefined', 'code "Iceland" should return undefined') | ||
t.type(getName('XX'), 'undefined', 'code "XX" should return undefined') | ||
t.type(getName(''), 'undefined', 'empty code should return undefined') | ||
t.equal(countries.getName('IS'), 'Iceland', 'code "IS" should return Iceland') | ||
t.equal(countries.getName('is'), 'Iceland', 'code "is" should return Iceland') | ||
t.equal(typeof countries.getName('IS'), 'string', 'type of code "IS" is string') | ||
t.equal(typeof countries.getName('Iceland'), 'undefined', 'code "Iceland" should return undefined') | ||
t.equal(typeof countries.getName('XX'), 'undefined', 'code "XX" should return undefined') | ||
t.equal(typeof countries.getName(''), 'undefined', 'empty code should return undefined') | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
'use strict' | ||
|
||
var { test } = require('tap') | ||
var { getNames } = require('../') | ||
var data = require('../data.json') | ||
import { test } from 'tape' | ||
import { getNames } from '../country-list.js' | ||
import data from '../data.json' | ||
|
||
test('get all country names', function (t) { | ||
t.equal(getNames().length, data.length, 'country names should be as many as countries') | ||
t.ok(getNames().indexOf('Iceland') > -1, 'country names should include Iceland') | ||
t.ok(getNames().indexOf('iceland') === -1, 'country names is case-sensitive, does not include iceland') | ||
t.type(getNames(), Array, 'name list is an array') | ||
t.equal(countries.getNames().length, data.length, 'country names should be as many as countries') | ||
t.ok(countries.getNames().indexOf('Iceland') > -1, 'country names should include Iceland') | ||
t.ok(countries.getNames().indexOf('iceland') === -1, 'country names is case-sensitive, does not include iceland') | ||
t.ok(countries.getNames() instanceof Array, 'name list is an array') | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters