• Version 6.0.6
  • Published
  • 109 kB
  • 6 dependencies
  • BSD-3-Clause license


npm i @jupyterlab/coreutils
yarn add @jupyterlab/coreutils
pnpm add @jupyterlab/coreutils





function signalToPromise

signalToPromise: <T, U>(
signal: ISignal<T, U>,
timeout?: number
) => Promise<[T, U]>;
  • Convert a signal into a promise for the first emitted value.

    Parameter signal

    The signal we are listening to.

    Parameter timeout

    Timeout to wait for signal in ms (not timeout if not defined or 0)


    a Promise that resolves with a (sender, args) pair.


class ActivityMonitor

class ActivityMonitor<Sender, Args> implements IDisposable {}
  • A class that monitors activity on a signal.


constructor(options: ActivityMonitor.IOptions<Sender, Args>);
  • Construct a new activity monitor.

property activityStopped

readonly activityStopped: ISignal<
ActivityMonitor.IArguments<Sender, Args>
  • A signal emitted when activity has ceased.

property isDisposed

readonly isDisposed: boolean;
  • Test whether the monitor has been disposed.

    #### Notes This is a read-only property.

property timeout

timeout: number;
  • The timeout associated with the monitor, in milliseconds.

method dispose

dispose: () => void;
  • Dispose of the resources used by the activity monitor.


interface IChangedArgs

interface IChangedArgs<T, OldT = T, U extends string = string> {}
  • A generic interface for change emitter payloads.

property name

name: U;
  • The name of the changed attribute.

property newValue

newValue: T;
  • The new value of the changed attribute.

property oldValue

oldValue: OldT;
  • The old value of the changed attribute.


namespace ActivityMonitor

namespace ActivityMonitor {}
  • The namespace for ActivityMonitor statics.

interface IArguments

interface IArguments<Sender, Args> {}
  • The argument object for an activity timeout.

property args

args: Args;
  • The most recent argument object.

property sender

sender: Sender;
  • The most recent sender object.

interface IOptions

interface IOptions<Sender, Args> {}
  • The options used to construct a new ActivityMonitor.

property signal

signal: ISignal<Sender, Args>;
  • The signal to monitor.

property timeout

timeout?: number;
  • The activity timeout in milliseconds.

    The default is 1 second.

namespace MarkdownCodeBlocks

namespace MarkdownCodeBlocks {}
  • The namespace for code block functions which help in extract code from markdown text


const CODE_BLOCK_MARKER: string;

    function findMarkdownCodeBlocks

    findMarkdownCodeBlocks: (text: string) => MarkdownCodeBlock[];
    • Construct all code snippets from current text (this could be potentially optimized if we can cache and detect differences)

      Parameter text

      A string to parse codeblocks from


      An array of MarkdownCodeBlocks.

    function isMarkdown

    isMarkdown: (extension: string) => boolean;
    • Check whether the given file extension is a markdown extension

      Parameter extension

      A file extension


      true/false depending on whether this is a supported markdown extension

    class MarkdownCodeBlock

    class MarkdownCodeBlock {}


      constructor(startLine: number);

        property code

        code: string;

          property endLine

          endLine: number;

            property startLine

            startLine: number;

              namespace PageConfig

              namespace PageConfig {}
              • The namespace for PageConfig functions.

              variable defaultWorkspace

              const defaultWorkspace: string;

                function getBaseUrl

                getBaseUrl: () => string;
                • Get the base url for a Jupyter application, or the base url of the page.

                function getNBConvertURL

                getNBConvertURL: ({
                }: {
                path: string;
                format: string;
                download: boolean;
                }) => string;
                • Returns the URL converting this notebook to a certain format with nbconvert.

                function getNotebookVersion

                getNotebookVersion: () => [number, number, number];
                • Get the Notebook version info [major, minor, patch].

                function getOption

                getOption: (name: string) => string;
                • Get global configuration data for the Jupyter application.

                  Parameter name

                  The name of the configuration option.


                  The config value or an empty string if not found.

                  #### Notes All values are treated as strings. For browser based applications, it is assumed that the page HTML includes a script tag with the id jupyter-config-data containing the configuration as valid JSON. In order to support the classic Notebook, we fall back on checking for body data of the given name.

                  For node applications, it is assumed that the process was launched with a --jupyter-config-data option pointing to a JSON settings file.

                function getShareUrl

                getShareUrl: () => string;
                • Get the base url for sharing links (usually baseUrl)

                function getToken

                getToken: () => string;
                • Get the authorization token for a Jupyter application.

                function getTreeShareUrl

                getTreeShareUrl: () => string;
                • Get the tree url for shareable links. Usually the same as treeUrl, but overrideable e.g. when sharing with JupyterHub.

                function getTreeUrl

                getTreeUrl: () => string;
                • Get the tree url for a JupyterLab application.

                function getUrl

                getUrl: (options: IGetUrlOptions) => string;
                • Create a new URL given an optional mode and tree path.

                  This is used to create URLS when the mode or tree path change as the user changes mode or the current document in the main area. If fields in options are omitted, the value in PageConfig will be used.

                  Parameter options

                  IGetUrlOptions for the new path.

                function getWsUrl

                getWsUrl: (baseUrl?: string) => string;
                • Get the base websocket url for a Jupyter application, or an empty string.

                function setOption

                setOption: (name: string, value: string) => string;
                • Set global configuration data for the Jupyter application.

                  Parameter name

                  The name of the configuration option.

                  Parameter value

                  The value to set the option to.


                  The last config value or an empty string if it doesn't exist.

                interface IGetUrlOptions

                interface IGetUrlOptions {}
                • Options for getUrl

                property mode

                mode?: string;
                • The optional mode as a string 'single-document' or 'multiple-document'. If the mode argument is missing, it will be provided from the PageConfig.

                property toShare

                toShare?: boolean;
                • Whether the url is meant to be shared or not; default false.

                property treePath

                treePath?: string;
                • The optional tree path as as string. If treePath is not provided it will be provided from the PageConfig. If an empty string, the resulting path will not contain a tree portion.

                property workspace

                workspace?: string;
                • The optional workspace as a string. If this argument is missing, the value will be pulled from PageConfig. To use the default workspace (no /workspaces/ URL segment will be included) pass the string PageConfig.defaultWorkspace.

                namespace PageConfig.Extension

                namespace PageConfig.Extension {}
                • The namespace for page config Extension functions.

                variable deferred

                const deferred: string[];
                • The collection of deferred extensions in page config.

                variable disabled

                const disabled: string[];
                • The collection of disabled extensions in page config.

                function isDeferred

                isDeferred: (id: string) => boolean;
                • Returns whether a plugin is deferred.

                  Parameter id

                  The plugin ID.

                function isDisabled

                isDisabled: (id: string) => boolean;
                • Returns whether a plugin is disabled.

                  Parameter id

                  The plugin ID.

                namespace PathExt

                namespace PathExt {}
                • The namespace for path-related functions.

                  Note that Jupyter server paths do not start with a leading slash.

                function basename

                basename: (path: string, ext?: string) => string;
                • Return the last portion of a path. Similar to the Unix basename command. Often used to extract the file name from a fully qualified path.

                  Parameter path

                  The path to evaluate.

                  Parameter ext

                  An extension to remove from the result.

                function dirname

                dirname: (path: string) => string;
                • Get the directory name of a path, similar to the Unix dirname command. When an empty path is given, returns the root path.

                  Parameter path

                  The file path.

                function extname

                extname: (path: string) => string;
                • Get the extension of the path.

                  Parameter path

                  The file path.


                  the extension of the file.

                  #### Notes The extension is the string from the last occurrence of the . character to end of string in the last portion of the path, inclusive. If there is no . in the last portion of the path, or if the first character of the basename of path [[basename]] is ., then an empty string is returned.

                function join

                join: (...paths: string[]) => string;
                • Join all arguments together and normalize the resulting path. Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.

                  Parameter paths

                  The string paths to join.

                function normalize

                normalize: (path: string) => string;
                • Normalize a string path, reducing '..' and '.' parts. When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. When an empty path is given, returns the root path.

                  Parameter path

                  The string path to normalize.

                function normalizeExtension

                normalizeExtension: (extension: string) => string;
                • Normalize a file extension to be of the type '.foo'.

                  Parameter extension

                  the file extension.

                  #### Notes Adds a leading dot if not present and converts to lower case.

                function relative

                relative: (from: string, to: string) => string;
                • Solve the relative path from {from} to {to}.

                  Parameter from

                  The source path.

                  Parameter to

                  The target path.

                  #### Notes If from and to each resolve to the same path (after calling path.resolve() on each), a zero-length string is returned. If a zero-length string is passed as from or to, / will be used instead of the zero-length strings.

                function removeSlash

                removeSlash: (path: string) => string;
                • Remove the leading slash from a path.

                  Parameter path

                  : the path from which to remove a leading slash.

                function resolve

                resolve: (...parts: string[]) => string;
                • Resolve a sequence of paths or path segments into an absolute path. The root path in the application has no leading slash, so it is removed.

                  Parameter parts

                  The paths to join.

                  #### Notes The right-most parameter is considered {to}. Other parameters are considered an array of {from}.

                  Starting from leftmost {from} parameter, resolves {to} to an absolute path.

                  If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.

                namespace Text

                namespace Text {}
                • The namespace for text-related functions.

                function camelCase

                camelCase: (str: string, upper?: boolean) => string;
                • Given a 'snake-case', 'snake_case', 'snake:case', or 'snake case' string, will return the camel case version: 'snakeCase'.

                  Parameter str

                  : the snake-case input string.

                  Parameter upper

                  : default = false. If true, the first letter of the returned string will be capitalized.


                  the camel case version of the input string.

                function charIndexToJsIndex

                charIndexToJsIndex: (charIdx: number, text: string) => number;
                • Convert a unicode character offset to a javascript string index.

                  Parameter charIdx

                  The index in unicode characters

                  Parameter text

                  The text in which the offset is calculated


                  The js-native index

                function jsIndexToCharIndex

                jsIndexToCharIndex: (jsIdx: number, text: string) => number;
                • Convert a javascript string index into a unicode character offset

                  Parameter jsIdx

                  The javascript string index (counting surrogate pairs)

                  Parameter text

                  The text in which the offset is calculated


                  The unicode character offset

                function titleCase

                titleCase: (str: string) => string;
                • Given a string, title case the words in the string.

                  Parameter str

                  : the string to title case.


                  the same string, but with each word capitalized.

                namespace Time

                namespace Time {}
                • The namespace for date functions.

                function format

                format: (value: string | Date) => string;
                • Convenient helper to convert a timestring to a date format.

                  Parameter value

                  The date timestring or date object.


                  A formatted date.

                function formatHuman

                formatHuman: (value: string | Date) => string;
                • Convert a timestring to a human readable string (e.g. 'two minutes ago').

                  Parameter value

                  The date timestring or date object.


                  A formatted date.

                namespace URLExt

                namespace URLExt {}
                • The namespace for URL-related functions.

                function encodeParts

                encodeParts: (url: string) => string;
                • Encode the components of a multi-segment url.

                  Parameter url

                  The url to encode.


                  the encoded url.

                  #### Notes Preserves the '/' separators. Should not include the base url, since all parts are escaped.

                function getHostName

                getHostName: (url: string) => string;
                • Parse URL and retrieve hostname

                  Parameter url

                  The URL string to parse


                  a hostname string value

                function isLocal

                isLocal: (url: string) => boolean;
                • Test whether the url is a local url.

                  #### Notes This function returns false for any fully qualified url, including data:, file:, and // protocol URLs.

                function join

                join: (...parts: string[]) => string;
                • Join a sequence of url components and normalizes as in node path.join.

                  Parameter parts

                  The url components.


                  the joined url.

                function normalize

                normalize: {
                (url: string): string;
                (url: undefined): undefined;
                (url: string): string;
                • Normalize a url.

                function objectToQueryString

                objectToQueryString: (value: PartialJSONObject) => string;
                • Return a serialized object string suitable for a query.

                  Parameter object

                  The source object.


                  an encoded url query.

                  #### Notes Modified version of [stackoverflow](http://stackoverflow.com/a/30707423).

                function parse

                parse: (url: string) => IUrl;
                • Parse a url into a URL object.

                  Parameter urlString

                  The URL string to parse.


                  A URL object.

                function queryStringToObject

                queryStringToObject: (value: string) => { [key: string]: string };
                • Return a parsed object that represents the values in a query string.

                interface IUrl

                interface IUrl {}
                • The interface for a URL object

                property hash

                hash: string;
                • The "fragment" portion of the URL including the leading ASCII hash (#) character

                property host

                host: string;
                • The full lower-cased host portion of the URL, including the port if specified.

                property hostname

                hostname: string;
                • The lower-cased host name portion of the host component without the port included.

                property href

                href: string;
                • The full URL string that was parsed with both the protocol and host components converted to lower-case.

                property pathname

                pathname: string;
                • The entire path section of the URL.

                property port

                port: string;
                • The numeric port portion of the host component.

                property protocol

                protocol: string;
                • Identifies the URL's lower-cased protocol scheme.

                property search

                search?: string;
                • The search element, including leading question mark ('?'), if any, of the URL.

                Package Files (10)

                Dependencies (6)

                Dev Dependencies (12)

                Peer Dependencies (0)

                No peer dependencies.


                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@jupyterlab/coreutils.

                • Markdown
                • HTML
                  <a href="https://www.jsdocs.io/package/@jupyterlab/coreutils"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>