Socket
Socket
Sign inDemoInstall

find-versions

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    find-versions

Find semver versions in a string: `unicorn v1.2.3` → `1.2.3`


Version published
Weekly downloads
4.2M
increased by0.18%
Maintainers
1
Install size
9.08 kB
Created
Weekly downloads
 

Package description

What is find-versions?

The find-versions npm package is designed to extract version numbers from strings. It is useful for parsing and identifying version numbers in various formats from text, allowing developers to easily extract and manipulate version information programmatically.

What are find-versions's main functionalities?

Extracting version numbers from strings

This feature allows you to extract version numbers from a given string. The function returns an array of version numbers found within the string. It's particularly useful for parsing logs, documents, or any text content that may contain version numbers.

"const findVersions = require('find-versions');\nconsole.log(findVersions('unicorn v1.2.3')); //=> ['1.2.3']"

Extracting version numbers with options

This feature extends the basic functionality by allowing you to specify options for the extraction process. For example, setting the 'loose' option to true enables the function to match version numbers that don't strictly follow semantic versioning.

"const findVersions = require('find-versions');\nconsole.log(findVersions('cat 1.2.3 and dog 4.5.6', {loose: true})); //=> ['1.2.3', '4.5.6']"

Other packages similar to find-versions

Readme

Source

find-versions Build Status

Find semver versions in a string: unicorn v1.2.31.2.3

Install

$ npm install find-versions

Usage

const findVersions = require('find-versions');

findVersions('unicorn v1.2.3 rainbow 2.3.4+build.1');
//=> ['1.2.3', '2.3.4+build.1']

findVersions('cp (GNU coreutils) 8.22', {loose: true});
//=> ['8.22.0']

API

findVersions(stringWithVersions, [options])

stringWithVersions

Type: string

options

Type: Object

loose

Type: boolean Default: false

Also match non-semver versions like 1.88. They're coerced into semver compliant versions.

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 22 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc