Options
All
  • Public
  • Public/Protected
  • All
Menu

Module source/semver

Index

Variables

Variables

Const semver

semver: { expression: () => RegExp; isValid: (str: string) => boolean; remove: (str: string) => string; retrieve: (str: string) => RegExpMatchArray; swap: (str: string, newVer: string) => string } = ...

Type declaration

  • expression: () => RegExp
      • (): RegExp
      • Returns RegExp variable used to test for semver

        Returns RegExp

  • isValid: (str: string) => boolean
      • (str: string): boolean
      • Tests if argument is valid semver

        Basic usage example:

        const semver = require('stringman').semver; // or `import {semver} from 'stringman'`;
        const valid = semver.isValid('0.1.0');
        const invalid = semver.isValid('0,1.0-rt');
        console.log(valid); // true
        console.log(invalid); // false
        

        Parameters

        • str: string

        Returns boolean

  • remove: (str: string) => string
      • (str: string): string
      • Removes semver from string, trims, and returns result

        Basic usage example:

        const semver = require('stringman').semver; // or `import {semver} from 'stringman'`;
        const removed = semver.remove('this project started on version 0.1.0');
        console.log(removed); // 'this project started on version'
        

        Parameters

        • str: string

        Returns string

  • retrieve: (str: string) => RegExpMatchArray
      • (str: string): RegExpMatchArray
      • returns semver from string if present

        Basic usage example:

        const semver = require('stringman').semver; // or `import {semver} from 'stringman'`;
        const justSemver = semver.retrieve('this project started on version 0.1.0');
        console.log(justSemver); // ['0.1.0']
        

        Parameters

        • str: string

        Returns RegExpMatchArray

  • swap: (str: string, newVer: string) => string
      • (str: string, newVer: string): string
      • Takes a string with a semver, a second string, returns first string with semver swapped for second string

        Basic usage example:

        const semver = require('stringman').semver; // or `import {semver} from 'stringman'`;
        const swapped = semver.swapped('this project started on version 0.1.0', '1.5.8');
        console.log(removed); // 'this project started on version 1.5.8'
        

        Parameters

        • str: string
        • newVer: string

        Returns string

Generated using TypeDoc