Comparing version 3.5.16 to 3.5.17
@@ -5,2 +5,8 @@ # Changelog | ||
## [3.5.17][] - 2022-01-26 | ||
- Add function `nowDateTimeUTC(date?: Date, timeSep?: string): string` | ||
- Add case functions: `toLower`, `toCamel`, `spinalToCamel`, and `snakeToCamel` | ||
- Fixed floating bug in tests for `nowDateTimeUTC` | ||
## [3.5.16][] - 2021-10-10 | ||
@@ -128,3 +134,4 @@ | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.16....HEAD | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.17....HEAD | ||
[3.5.17]: https://github.com/metarhia/metautil/compare/v3.5.16...v3.5.17 | ||
[3.5.16]: https://github.com/metarhia/metautil/compare/v3.5.15...v3.5.16 | ||
@@ -131,0 +138,0 @@ [3.5.15]: https://github.com/metarhia/metautil/compare/v3.5.14...v3.5.15 |
@@ -88,2 +88,14 @@ 'use strict'; | ||
const toLower = (s) => s.toLowerCase(); | ||
const toCamel = (separator) => (s) => { | ||
const words = s.split(separator); | ||
const first = words.length > 0 ? words.shift().toLowerCase() : ''; | ||
return first + words.map(toLower).map(toUpperCamel).join(''); | ||
}; | ||
const spinalToCamel = toCamel('-'); | ||
const snakeToCamel = toCamel('_'); | ||
const isConstant = (s) => s === s.toUpperCase(); | ||
@@ -105,2 +117,13 @@ | ||
const nowDateTimeUTC = (date, timeSep = ':') => { | ||
if (!date) date = new Date(); | ||
const yyyy = date.getUTCFullYear().toString(); | ||
const mm = twoDigit(date.getUTCMonth() + 1); | ||
const dd = twoDigit(date.getUTCDate()); | ||
const hh = twoDigit(date.getUTCHours()); | ||
const min = twoDigit(date.getUTCMinutes()); | ||
const ss = twoDigit(date.getUTCSeconds()); | ||
return `${yyyy}-${mm}-${dd}T${hh}${timeSep}${min}${timeSep}${ss}`; | ||
}; | ||
const DURATION_UNITS = { | ||
@@ -319,4 +342,9 @@ d: 86400, // days | ||
toUpperCamel, | ||
toLower, | ||
toCamel, | ||
spinalToCamel, | ||
snakeToCamel, | ||
isConstant, | ||
nowDate, | ||
nowDateTimeUTC, | ||
duration, | ||
@@ -323,0 +351,0 @@ bytesToSize, |
@@ -36,4 +36,9 @@ import { EventEmitter } from 'events'; | ||
export function toUpperCamel(s: string): string; | ||
export function toLower(s: string): string; | ||
export function toCamel(separator: string): (s: string) => string; | ||
export function spinalToCamel(s: string): string; | ||
export function snakeToCamel(s: string): string; | ||
export function isConstant(s: string): boolean; | ||
export function nowDate(date?: Date): string; | ||
export function nowDateTimeUTC(date?: Date, timeSep?: string): string; | ||
export function duration(s: string | number): number; | ||
@@ -40,0 +45,0 @@ export function bytesToSize(bytes: number): string; |
{ | ||
"name": "metautil", | ||
"version": "3.5.16", | ||
"version": "3.5.17", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31973
725
376
1