Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

semver-parser

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver-parser - npm Package Compare versions

Comparing version 3.1.1 to 4.0.0

13

index.js

@@ -7,13 +7,6 @@ /**

*/
'use strict';
/* api */
const {
export {
compareSemVer, isValidSemVer, parseSemVer, promises
} = require('./modules/semver');
module.exports = {
compareSemVer,
isValidSemVer,
parseSemVer,
promises
};
} from './modules/semver.js';
/**
* common.js
*/
'use strict';
/* constants */

@@ -15,3 +15,3 @@ const TYPE_FROM = 8;

*/
const throwErr = e => {
export const throwErr = e => {
throw e;

@@ -26,3 +26,3 @@ };

*/
const logErr = e => {
export const logErr = e => {
console.error(e);

@@ -38,3 +38,3 @@ return false;

*/
const logWarn = msg => {
export const logWarn = msg => {
msg && console.warn(msg);

@@ -50,3 +50,3 @@ return false;

*/
const logMsg = msg => {
export const logMsg = msg => {
msg && console.log(msg);

@@ -62,3 +62,3 @@ return msg;

*/
const getType = o =>
export const getType = o =>
Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);

@@ -72,68 +72,2 @@

*/
const isString = o => typeof o === 'string' || o instanceof String;
/**
* stringify positive integer
*
* @param {number} i - integer
* @param {boolean} [zero] - treat 0 as a positive integer
* @returns {?string} - stringified integer
*/
const stringifyPositiveInt = (i, zero = false) =>
Number.isSafeInteger(i) && ((zero && i >= 0) || i > 0) ? `${i}` : null;
/**
* parse stringified integer
*
* @param {string} i - stringified integer
* @param {boolean} [zero] - accept leading zero
* @returns {number} - integer
*/
const parseStringifiedInt = (i, zero = false) => {
if (!isString(i)) {
throw new TypeError(`Expexted String but got ${getType(i)}`);
}
if (!zero && !/^-?(?:0|[1-9]\d*)$/.test(i)) {
throw new Error(`${i} is not a stringified integer.`);
}
return parseInt(i);
};
/**
* escape matching char
*
* @param {string} str - argument
* @param {RegExp} re - RegExp
* @returns {?string} - string
*/
const escapeChar = (str, re) =>
isString(str) && re && re.global ? str.replace(re, (m, c) => `\\${c}`) : null;
/**
* strip HTML tags and decode HTML entities
*
* @param {string} v - value
* @returns {string} - converted value
*/
const stripHtmlTags = v => {
while (/^\n*<(?:[^>]+:)?[^>]+?>|<\/(?:[^>]+:)?[^>]+>\n*$/.test(v)) {
v = v.replace(/^\n*<(?:[^>]+:)?[^>]+?>/, '')
.replace(/<\/(?:[^>]+:)?[^>]+>\n*$/, '\n');
}
return v.replace(/<\/(?:[^>]+:)?[^>]+>\n*<!--.*-->\n*<(?:[^>]+:)?[^>]+>/g, '\n\n')
.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"')
.replace(/&amp;/g, '&');
};
module.exports = {
escapeChar,
getType,
isString,
logErr,
logMsg,
logWarn,
parseStringifiedInt,
stringifyPositiveInt,
stripHtmlTags,
throwErr
};
export const isString = o => typeof o === 'string' || o instanceof String;

@@ -7,5 +7,5 @@ /**

*/
'use strict';
/* api */
const { getType, isString } = require('./common');
import { getType, isString } from './common.js';

@@ -32,3 +32,3 @@ /* constants */

*/
const isValidSemVer = (version, strict = false) => {
export const isValidSemVer = (version, strict = false) => {
if (!isString(version)) {

@@ -48,3 +48,3 @@ throw new TypeError(`Expected String but got ${getType(version)}.`);

*/
const parseVersionPart = (part, nonPosInt = false) => {
export const parseVersionPart = (part, nonPosInt = false) => {
if (!isString(part)) {

@@ -76,3 +76,3 @@ throw new TypeError(`Expected String but got ${getType(part)}.`);

*/
const compareSemVer = (version, base, strict = false) => {
export const compareSemVer = (version, base, strict = false) => {
if (!isString(version)) {

@@ -168,3 +168,3 @@ throw new TypeError(`Expected String but got ${getType(version)}.`);

*/
const parseSemVer = (version, strict = false) => {
export const parseSemVer = (version, strict = false) => {
if (!isString(version)) {

@@ -203,3 +203,3 @@ throw new TypeError(`Expected String but got ${getType(version)}.`);

*/
const compareSemVerAsync = async (version, base, strict = false) => {
export const compareSemVerAsync = async (version, base, strict = false) => {
const res = await compareSemVer(version, base, strict);

@@ -216,3 +216,3 @@ return res;

*/
const isValidSemVerAsync = async (version, strict = false) => {
export const isValidSemVerAsync = async (version, strict = false) => {
const res = await isValidSemVer(version, strict);

@@ -237,3 +237,3 @@ return res;

*/
const parseSemVerAsync = async (version, strict = false) => {
export const parseSemVerAsync = async (version, strict = false) => {
const res = await parseSemVer(version, strict);

@@ -243,12 +243,6 @@ return res;

module.exports = {
compareSemVer,
isValidSemVer,
parseSemVer,
parseVersionPart,
promises: {
compareSemVer: compareSemVerAsync,
isValidSemVer: isValidSemVerAsync,
parseSemVer: parseSemVerAsync
}
export const promises = {
compareSemVer: compareSemVerAsync,
isValidSemVer: isValidSemVerAsync,
parseSemVer: parseSemVerAsync
};

@@ -13,19 +13,20 @@ {

"main": "./index.js",
"type": "module",
"scripts": {
"lint": "eslint --fix .",
"test": "nyc --reporter=text mocha test --exit"
"test": "c8 --reporter=text mocha test --exit"
},
"devDependencies": {
"c8": "^7.9.0",
"chai": "^4.3.4",
"eslint": "^7.29.0",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.4.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"mocha": "^9.0.1",
"nyc": "^15.1.0",
"sinon": "^11.1.1"
"mocha": "^9.1.2",
"sinon": "^11.1.2"
},
"version": "3.1.1"
"version": "4.0.0"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc