Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@lazy-node/semver-simple-parse

bluelovers234APACHEv23.0.1TypeScript support: included

Tools for manipulating semver strings and objects

semver, parse, parseRange, range

readme

semver-utils.js

| Sponsored by ppl

Some utils that aren't provided by the mainstream semver module.

Usage

npm install --save semver-utils
'use strict';

var semverUtils = require('semver-utils');
var version = require('./package.json').version;
var semver = semverUtils.parse(version);

console.log(semver);

API

  • semverUtils.parse(semverString)
  • semverUtils.stringify(semverObject)
  • semverUtils.parseRange(rangeString)
  • semverUtils.stringifyRange(rangeArray)

semverUtils.parse(semverString)

Turns a string such as 1.0.6-1+build-623 into the object

{ semver:   '1.0.6-1+build-623'
, version:  '1.0.6'
, major:    '1'
, minor:    '0'
, patch:    '6'
, release:  '1'
, build:    'build-623'
}

returns null on error

semverUtils.stringify(semverObject)

Creates a string such as 1.0.6-1+build-623 from the object

{ major:    '1'
, minor:    '0'
, patch:    '6'
, release:  '1'
, build:    'build-623'
}

semverUtils.parseRange(rangeString)

A solution to https://github.com/isaacs/node-semver/issues/10

Parses a range string into an array of semver objects

>= 1.1.7 < 2.0.0 || 1.1.3 becomes

[
    {
        "semver": ">= v1.1.7"
      , "operator": ">="
      , "major": 1
      , "minor": 1
      , "patch": 7
    }
  , {
        "semver": "< v2.0.0"
      , "operator": "<"
      , "major": 2
      , "minor": 0
      , "patch": 0
    }
  , {
        "operator": "||"
    }
  , {
        "semver": "v1.1.3"
      , "operator": "="
      , "major": 1
      , "minor": 1
      , "patch": 3
    }

]

semverUtils.stringifyRange(rangeArray)

Creates a range string such as >= 1.1.7 < 2.0.0 || 1.1.3 from an array of semver objects (and operators) such as

[
    { "semver": ">= v1.1.7"
    , "operator": ">="
    , "major": 1
    , "minor": 1
    , "patch": 7
    }
  , { "semver": "< v2.0.0"
    , "operator": "<"
    , "major": 2
    , "minor": 0
    , "patch": 0
    }
  , { "operator": "||"
    }
  , { "semver": "v1.1.3"
    , "operator": "="
    , "major": 1
    , "minor": 1
    , "patch": 3
    }

]

Obsolete Work

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.0.1 (2024-05-03)

🛠 Build System

3.0.0 (2023-10-10)

📌 Dependencies

2.0.9 (2022-11-14)

📌 Dependencies

2.0.8 (2022-10-28)

📌 Dependencies

2.0.7 (2022-10-01)

🔖 Miscellaneous

2.0.6 (2022-09-29)

🔖 Miscellaneous

2.0.5 (2022-09-27)

🔖 Miscellaneous

2.0.4 (2022-09-06)

📚 Documentation

🔖 Miscellaneous

2.0.3 (2022-08-26)

🚨 Tests

  • snapshot: snapshots updated (50bff7c)

🔖 Miscellaneous

2.0.2 (2022-08-13)

🚨 Tests

  • update jest.config.js and deps (d1d501b)

🛠 Build System

📌 Dependencies

2.0.1 (2022-07-31)

🚨 Tests

  • preset: use @bluelovers/jest-config (e239ecf)

2.0.0 (2022-07-07)

✨ Features

  • add replaceSimpleSemVerVersion (4a143dc)

1.1.33 (2022-05-11)

♻️ Chores

1.1.32 (2022-03-14)

🔖 Miscellaneous

1.1.31 (2022-02-27)

♻️ Chores

1.1.30 (2022-02-27)

♻️ Chores

1.1.29 (2022-02-05)

💎 Styles

  • typescript: 固定 type 順序 來防止 typescript 隨機排序 (abacff2)

1.1.28 (2022-02-01)

🔖 Miscellaneous

1.1.27 (2022-01-25)

Note: Version bump only for package @lazy-node/semver-simple-parse

1.1.26 (2022-01-13)

Note: Version bump only for package @lazy-node/semver-simple-parse

1.1.25 (2021-12-16)

🔖 Miscellaneous

1.1.24 (2021-12-06)

🔖 Miscellaneous

1.1.23 (2021-12-06)

♻️ Chores

1.1.22 (2021-12-06)

♻️ Chores

1.1.21 (2021-11-30)

🔖 Miscellaneous

1.1.20 (2021-11-28)

♻️ Chores

1.1.19 (2021-11-23)

♻️ Chores

🔖 Miscellaneous

1.1.18 (2021-11-23)

♻️ Chores

1.1.17 (2021-09-15)

♻️ Chores

1.1.16 (2021-08-13)

♻️ Chores

1.1.15 (2021-07-23)

♻️ Chores

1.1.14 (2021-07-16)

✨ Features

🔖 Miscellaneous

1.1.13 (2021-07-16)

✨ Features

1.1.12 (2021-07-13)

Note: Version bump only for package @lazy-node/semver-simple-parse

1.1.11 (2021-07-11)

♻️ Chores

  • deps: package-json <7 >=6.5 (95d11aa)

1.1.10 (2021-07-11)

🛠 Build System

🔖 Miscellaneous

1.1.9 (2021-07-11)

🛠 Build System

1.1.8 (2021-06-21)

♻️ Chores

1.1.7 (2020-09-04)

♻️ Chores

1.1.6 (2020-08-11)

🔖 Miscellaneous

1.1.5 (2020-08-11)

🐛 Bug Fixes

✨ Features

📦 Code Refactoring

♻️ Chores

🔖 Miscellaneous

  • . (6ee19c3)
  • Add 'packages/@lazy-node/semver-parse/' from commit '2344adc3b2d6b5683e7823105aab6a9fd936a33c' (f9a35d5)

1.1.4 (2020-08-11)

🐛 Bug Fixes

✨ Features

📦 Code Refactoring

♻️ Chores

🔖 Miscellaneous

  • Add 'packages/@lazy-node/semver-parse/' from commit '2344adc3b2d6b5683e7823105aab6a9fd936a33c' (f9a35d5)