@jupyterlab/coreutils
Advanced tools
Comparing version 6.2.0-beta.1 to 6.2.0-beta.2
@@ -99,5 +99,5 @@ /** | ||
* | ||
* @param path: the path from which to remove a leading slash. | ||
* @param path the path from which to remove a leading slash. | ||
*/ | ||
function removeSlash(path: string): string; | ||
} |
@@ -142,3 +142,3 @@ "use strict"; | ||
* | ||
* @param path: the path from which to remove a leading slash. | ||
* @param path the path from which to remove a leading slash. | ||
*/ | ||
@@ -145,0 +145,0 @@ function removeSlash(path) { |
@@ -29,5 +29,5 @@ /** | ||
* | ||
* @param str: the snake-case input string. | ||
* @param str the snake-case input string. | ||
* | ||
* @param upper: default = false. If true, the first letter of the | ||
* @param upper default = false. If true, the first letter of the | ||
* returned string will be capitalized. | ||
@@ -41,3 +41,3 @@ * | ||
* | ||
* @param str: the string to title case. | ||
* @param str the string to title case. | ||
* | ||
@@ -44,0 +44,0 @@ * @returns the same string, but with each word capitalized. |
@@ -79,5 +79,5 @@ "use strict"; | ||
* | ||
* @param str: the snake-case input string. | ||
* @param str the snake-case input string. | ||
* | ||
* @param upper: default = false. If true, the first letter of the | ||
* @param upper default = false. If true, the first letter of the | ||
* returned string will be capitalized. | ||
@@ -101,3 +101,3 @@ * | ||
* | ||
* @param str: the string to title case. | ||
* @param str the string to title case. | ||
* | ||
@@ -104,0 +104,0 @@ * @returns the same string, but with each word capitalized. |
@@ -5,2 +5,3 @@ /** | ||
export declare namespace Time { | ||
type HumanStyle = 'long' | 'short' | 'narrow'; | ||
/** | ||
@@ -13,3 +14,3 @@ * Convert a timestring to a human readable string (e.g. 'two minutes ago'). | ||
*/ | ||
function formatHuman(value: string | Date): string; | ||
function formatHuman(value: string | Date, format?: HumanStyle): string; | ||
/** | ||
@@ -16,0 +17,0 @@ * Convenient helper to convert a timestring to a date format. |
@@ -29,5 +29,8 @@ "use strict"; | ||
*/ | ||
function formatHuman(value) { | ||
function formatHuman(value, format = 'long') { | ||
const lang = document.documentElement.lang || 'en'; | ||
const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }); | ||
const formatter = new Intl.RelativeTimeFormat(lang, { | ||
numeric: 'auto', | ||
style: format | ||
}); | ||
const delta = new Date(value).getTime() - Date.now(); | ||
@@ -34,0 +37,0 @@ for (let unit of UNITS) { |
@@ -9,3 +9,3 @@ import { PartialJSONObject } from '@lumino/coreutils'; | ||
* | ||
* @param urlString - The URL string to parse. | ||
* @param url - The URL string to parse. | ||
* | ||
@@ -52,3 +52,3 @@ * @returns A URL object. | ||
* | ||
* @param object - The source object. | ||
* @param value The source object. | ||
* | ||
@@ -55,0 +55,0 @@ * @returns an encoded url query. |
@@ -19,3 +19,3 @@ "use strict"; | ||
* | ||
* @param urlString - The URL string to parse. | ||
* @param url - The URL string to parse. | ||
* | ||
@@ -87,3 +87,3 @@ * @returns A URL object. | ||
* | ||
* @param object - The source object. | ||
* @param value The source object. | ||
* | ||
@@ -90,0 +90,0 @@ * @returns an encoded url query. |
{ | ||
"name": "@jupyterlab/coreutils", | ||
"version": "6.2.0-beta.1", | ||
"version": "6.2.0-beta.2", | ||
"description": "JupyterLab - Core Utilities", | ||
@@ -35,3 +35,2 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", | ||
"docs": "typedoc src", | ||
"test": "jest", | ||
@@ -62,3 +61,2 @@ "test:cov": "jest --collect-coverage", | ||
"ts-jest": "^29.1.0", | ||
"typedoc": "~0.24.7", | ||
"typescript": "~5.1.6" | ||
@@ -65,0 +63,0 @@ }, |
@@ -140,3 +140,3 @@ // Copyright (c) Jupyter Development Team. | ||
* | ||
* @param path: the path from which to remove a leading slash. | ||
* @param path the path from which to remove a leading slash. | ||
*/ | ||
@@ -143,0 +143,0 @@ export function removeSlash(path: string): string { |
@@ -78,5 +78,5 @@ // Copyright (c) Jupyter Development Team. | ||
* | ||
* @param str: the snake-case input string. | ||
* @param str the snake-case input string. | ||
* | ||
* @param upper: default = false. If true, the first letter of the | ||
* @param upper default = false. If true, the first letter of the | ||
* returned string will be capitalized. | ||
@@ -99,3 +99,3 @@ * | ||
* | ||
* @param str: the string to title case. | ||
* @param str the string to title case. | ||
* | ||
@@ -102,0 +102,0 @@ * @returns the same string, but with each word capitalized. |
@@ -20,2 +20,6 @@ // Copyright (c) Jupyter Development Team. | ||
export namespace Time { | ||
// Intl.RelativeTimeFormatStyle contains these, but it requires `ES2020.Intl`. | ||
// We currently compile to an `ES2018` target. | ||
export type HumanStyle = 'long' | 'short' | 'narrow'; | ||
/** | ||
@@ -28,5 +32,11 @@ * Convert a timestring to a human readable string (e.g. 'two minutes ago'). | ||
*/ | ||
export function formatHuman(value: string | Date): string { | ||
export function formatHuman( | ||
value: string | Date, | ||
format: HumanStyle = 'long' | ||
): string { | ||
const lang = document.documentElement.lang || 'en'; | ||
const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }); | ||
const formatter = new Intl.RelativeTimeFormat(lang, { | ||
numeric: 'auto', | ||
style: format | ||
}); | ||
const delta = new Date(value).getTime() - Date.now(); | ||
@@ -33,0 +43,0 @@ for (let unit of UNITS) { |
@@ -15,3 +15,3 @@ // Copyright (c) Jupyter Development Team. | ||
* | ||
* @param urlString - The URL string to parse. | ||
* @param url - The URL string to parse. | ||
* | ||
@@ -93,3 +93,3 @@ * @returns A URL object. | ||
* | ||
* @param object - The source object. | ||
* @param value The source object. | ||
* | ||
@@ -96,0 +96,0 @@ * @returns an encoded url query. |
Sorry, the diff of this file is not supported yet
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
114925
11
2784