Use ES6 import/export (#139)

* Use ES6 import/export

* Fix tests
This commit is contained in:
Jaco Greeff
2018-06-20 16:36:07 +02:00
committed by GitHub
parent 7a694c075c
commit 99b86d9849
263 changed files with 841 additions and 814 deletions
+2 -2
View File
@@ -3,11 +3,11 @@
// of the ISC license. See the LICENSE file for details.
// @flow
const stringShorten = require('./shorten');
import stringShorten from './shorten';
/**
@summary Utility methods to convert to work with `string` values
*/
module.exports = {
export {
stringShorten
};
+2 -2
View File
@@ -14,7 +14,7 @@
stringShorten('1234567890', 2); // => 12..90
*/
module.exports = function stringShorten (_value: mixed, prefixLength: number = 6): string {
export default function stringShorten (_value: mixed, prefixLength: number = 6): string {
// $FlowFixMe coerced into string (by any means)
const value = `${_value}`;
@@ -23,4 +23,4 @@ module.exports = function stringShorten (_value: mixed, prefixLength: number = 6
}
return `${value.substr(0, prefixLength)}..${value.slice(-prefixLength)}`;
};
}
+1 -1
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const { stringShorten } = require('./index');
import { stringShorten } from './index';
describe('stringShorten', () => {
it('returns the value as-is when <= maxLength', () => {