Sha256: 698791cf41b278d6eb4bb5dcb039efc189832c32847c5f8fc0fb6d5f5c4cf08f

Contents?: true

Size: 729 Bytes

Versions: 45

Compression:

Stored size: 729 Bytes

Contents

/**
 * @author Toru Nagashima <https://github.com/mysticatea>
 * See LICENSE file in root directory for full license.
 */
"use strict"

const { Range } = require("semver")
const cache = new Map()

/**
 * Get the `semver.Range` object of a given range text.
 * @param {string} x The text expression for a semver range.
 * @returns {Range|null} The range object of a given range text.
 * It's null if the `x` is not a valid range text.
 */
module.exports = function getSemverRange(x) {
    const s = String(x)
    let ret = cache.get(s) || null

    if (!ret) {
        try {
            ret = new Range(s)
        } catch (_error) {
            // Ignore parsing error.
        }
        cache.set(s, ret)
    }

    return ret
}

Version data entries

45 entries across 44 versions & 2 rubygems

Version Path
decidim-0.26.8 packages/eslint-config/node_modules/eslint-plugin-n/lib/util/get-semver-range.js
decidim-0.26.8 packages/eslint-config/node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-18.0.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.21.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.20.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.19.1 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.19.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.18.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.17.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.16.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.15.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.14.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.13.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.12.2 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.12.1 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.12.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.11.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.10.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.9.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js
govuk_publishing_components-17.8.0 node_modules/eslint-plugin-node/lib/util/get-semver-range.js