From 39c7bcc1b76db1b45f981f280b6a122fc29688b5 Mon Sep 17 00:00:00 2001 From: Rui Araujo Date: Fri, 6 Oct 2023 16:25:13 +0200 Subject: [PATCH] Add support for milli memory declarations. --- index.js | 1 + index.test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/index.js b/index.js index 0c69b1d..ae8d975 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ function cpuParser(input) { } const memoryMultipliers = { + m: 0.001, k: 1000, M: 1000 ** 2, G: 1000 ** 3, diff --git a/index.test.js b/index.test.js index 24ba76d..bc478b7 100644 --- a/index.test.js +++ b/index.test.js @@ -20,6 +20,7 @@ describe('a memory parser', () => { // pattern is [description, input, output] const tests = [ ['parses full numbers', '1', 1], + ['parses milli strings', '1000m', 1], ['parses kilo strings', '1k', 1 * (1000 ** 1)], ['parses Mega strings', '2M', 2 * (1000 ** 2)], ['parses Giga strings', '3G', 3 * (1000 ** 3)],