Finish refactoring src/**/*.js to use import & export

This commit is contained in:
Tankred Hase
2016-02-05 15:19:49 +07:00
parent 70ac662073
commit 8728db2b08
18 changed files with 54 additions and 86 deletions

View File

@@ -30,12 +30,10 @@
import util from '../util.js';
module.exports = Keyid;
/**
* @constructor
*/
function Keyid() {
export default function Keyid() {
this.bytes = '';
}
@@ -63,17 +61,17 @@ Keyid.prototype.isNull = function() {
return this.bytes === '';
};
module.exports.mapToHex = function (keyId) {
Keyid.mapToHex = function (keyId) {
return keyId.toHex();
};
module.exports.fromClone = function (clone) {
Keyid.fromClone = function (clone) {
var keyid = new Keyid();
keyid.bytes = clone.bytes;
return keyid;
};
module.exports.fromId = function (hex) {
Keyid.fromId = function (hex) {
var keyid = new Keyid();
keyid.read(util.hex2bin(hex));
return keyid;

View File

@@ -39,12 +39,10 @@
import BigInteger from '../crypto/public_key/jsbn.js';
import util from '../util.js';
module.exports = MPI;
/**
* @constructor
*/
function MPI() {
export default function MPI() {
/** An implementation dependent integer */
this.data = null;
}
@@ -109,7 +107,7 @@ MPI.prototype.fromBigInteger = function (bn) {
this.data = bn.clone();
};
module.exports.fromClone = function (clone) {
MPI.fromClone = function (clone) {
clone.data.copyTo = BigInteger.prototype.copyTo;
var bn = new BigInteger();
clone.data.copyTo(bn);

View File

@@ -35,12 +35,10 @@ import enums from '../enums.js';
import util from '../util.js';
import crypto from '../crypto';
module.exports = S2K;
/**
* @constructor
*/
function S2K() {
export default function S2K() {
/** @type {module:enums.hash} */
this.algorithm = 'sha256';
/** @type {module:enums.s2k} */
@@ -201,7 +199,7 @@ S2K.prototype.produce_key = function (passphrase, numBytes) {
return util.concatUint8Array(arr).subarray(0, numBytes);
};
module.exports.fromClone = function (clone) {
S2K.fromClone = function (clone) {
var s2k = new S2K();
s2k.algorithm = clone.algorithm;
s2k.type = clone.type;