From 4f4688517dee47bc39b7f09b6d74ea3e81c03788 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Thu, 23 May 2019 15:45:17 +0100 Subject: [PATCH] fix: remove leftpad (#16) --- package.json | 1 - src/utils.js | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 843b73d..bf33f53 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "async": "^2.6.2", "buffer-split": "^1.0.0", "err-code": "^1.1.2", - "left-pad": "^1.3.0", "multihashes": "~0.4.14", "multihashing-async": "~0.6.0", "protons": "^1.0.1" diff --git a/src/utils.js b/src/utils.js index 3b2fb2b..73490fc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,7 +1,5 @@ 'use strict' -const leftPad = require('left-pad') - /** * Convert a JavaScript date into an `RFC3339Nano` formatted * string. @@ -11,11 +9,11 @@ const leftPad = require('left-pad') */ module.exports.toRFC3339 = (time) => { const year = time.getUTCFullYear() - const month = leftPad(time.getUTCMonth() + 1, 2, '0') - const day = leftPad(time.getUTCDate(), 2, '0') - const hour = leftPad(time.getUTCHours(), 2, '0') - const minute = leftPad(time.getUTCMinutes(), 2, '0') - const seconds = leftPad(time.getUTCSeconds(), 2, '0') + const month = String(time.getUTCMonth() + 1).padStart(2, '0') + const day = String(time.getUTCDate()).padStart(2, '0') + const hour = String(time.getUTCHours()).padStart(2, '0') + const minute = String(time.getUTCMinutes()).padStart(2, '0') + const seconds = String(time.getUTCSeconds()).padStart(2, '0') const milliseconds = time.getUTCMilliseconds() const nanoseconds = milliseconds * 1000 * 1000