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,7 +3,7 @@
// of the ISC license. See the LICENSE file for details.
// @flow
const bufferFromU8a = require('../u8a/toBuffer');
import bufferFromU8a from '../u8a/toBuffer';
/**
@name bufferFromU8a
@@ -11,4 +11,4 @@ const bufferFromU8a = require('../u8a/toBuffer');
@summary Creates a Buffer object from a Uint8Array.
@alias u8a/toBuffer
*/
module.exports = bufferFromU8a;
export default bufferFromU8a;
+2 -2
View File
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const isFunction = require('../is/function');
import isFunction from '../is/function';
const { bufferFromU8a } = require('./index');
import { bufferFromU8a } from './index';
describe('bufferFromU8a', () => {
it('exists as a function', () => {
+3 -3
View File
@@ -3,13 +3,13 @@
// of the ISC license. See the LICENSE file for details.
// @flow
const bufferFromU8a = require('./fromU8a');
const bufferToU8a = require('./toU8a');
import bufferFromU8a from './fromU8a';
import bufferToU8a from './toU8a';
/**
@summary Utility methods to convert to and from `Buffer` objects
*/
module.exports = {
export {
bufferFromU8a,
bufferToU8a
};
+2 -2
View File
@@ -14,10 +14,10 @@
bufferToU8a(Buffer.from([1, 2, 3]));
*/
module.exports = function bufferToU8a (buffer?: Buffer): Uint8Array {
export default function bufferToU8a (buffer?: Buffer): Uint8Array {
if (!buffer) {
return new Uint8Array([]);
}
return new Uint8Array(buffer);
};
}
+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 { bufferToU8a } = require('./index');
import { bufferToU8a } from './index';
describe('bufferToU8a', () => {
it('returns an empty buffer when null provided', () => {