@transloadit/format-duration-ms
Advanced tools
| # @transloadit/format-duration-ms | ||
| ## 0.4.3 | ||
| ### Patch Changes | ||
| - 07ca1ed: Switch to turbo |
@@ -1,1 +0,2 @@ | ||
| export default function formatDurationMs(ms: number): string; | ||
| declare const _default: (ms: number) => string; | ||
| export = _default; |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const pretty_ms_1 = __importDefault(require("pretty-ms")); | ||
| function formatDurationMs(ms) { | ||
| let human = (0, pretty_ms_1.default)(ms); | ||
| const prettyMS = require("pretty-ms"); | ||
| module.exports = function formatDurationMs(ms) { | ||
| let human = prettyMS(ms); | ||
| human = human.replace(/(\d+)\.\d+s/g, '$1s'); | ||
| human = human.replace(/\s+/g, ''); | ||
| return human; | ||
| } | ||
| exports.default = formatDurationMs; | ||
| }; | ||
| //# sourceMappingURL=formatDurationMs.js.map |
+6
-9
| { | ||
| "name": "@transloadit/format-duration-ms", | ||
| "version": "0.4.2", | ||
| "version": "0.4.3", | ||
| "repository": { | ||
@@ -12,9 +12,7 @@ "type": "git", | ||
| "types": "dist/formatDurationMs.d.ts", | ||
| "directories": { | ||
| "lib": "dist", | ||
| "test": "dist" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: run tests from root\" && exit 1", | ||
| "tsc": "tsc --build --clean && tsc --build" | ||
| "build": "tsc --build --clean && tsc --build", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "tsx --test src/**/*.test.ts", | ||
| "test:watch": "tsx --test --watch src/**/*.test.ts" | ||
| }, | ||
@@ -26,4 +24,3 @@ "dependencies": { | ||
| "access": "public" | ||
| }, | ||
| "gitHead": "412a97c914bd1a8c6d21df01c9f7e18ab19b218a" | ||
| } | ||
| } |
@@ -0,3 +1,3 @@ | ||
| import assert from 'node:assert' | ||
| import { describe, test } from 'node:test' | ||
| import assert from 'node:assert' | ||
| import formatDurationMs from './formatDurationMs' | ||
@@ -4,0 +4,0 @@ |
| export {}; |
| "use strict"; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const formatDurationMs_1 = __importDefault(require("./formatDurationMs")); | ||
| describe('formatDurationMs', () => { | ||
| test('main', () => __awaiter(void 0, void 0, void 0, function* () { | ||
| expect((0, formatDurationMs_1.default)(-10)).toBe('-10ms'); | ||
| expect((0, formatDurationMs_1.default)(10)).toBe('10ms'); | ||
| expect((0, formatDurationMs_1.default)(1000)).toBe('1s'); | ||
| expect((0, formatDurationMs_1.default)(1001)).toBe('1s'); | ||
| expect((0, formatDurationMs_1.default)(100000)).toBe('1m40s'); | ||
| expect((0, formatDurationMs_1.default)(10000000)).toBe('2h46m40s'); | ||
| expect((0, formatDurationMs_1.default)(1000000000)).toBe('11d13h46m40s'); | ||
| expect((0, formatDurationMs_1.default)(100000000000)).toBe('3y62d9h46m40s'); | ||
| })); | ||
| }); | ||
| //# sourceMappingURL=formatDurationMs.test.js.map |
| {"version":3,"file":"formatDurationMs.test.js","sourceRoot":"","sources":["../src/formatDurationMs.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,0EAAiD;AAEjD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,MAAM,EAAE,GAAS,EAAE;QACtB,MAAM,CAAC,IAAA,0BAAgB,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAA,0BAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACzC,MAAM,CAAC,IAAA,0BAAgB,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,CAAC,IAAA,0BAAgB,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,CAAC,IAAA,0BAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,CAAC,IAAA,0BAAgB,EAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACnD,MAAM,CAAC,IAAA,0BAAgB,EAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACzD,MAAM,CAAC,IAAA,0BAAgB,EAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC9D,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} |
Sorry, the diff of this file is not supported yet
37118
-7.15%11
-8.33%40
-44.44%