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

bowhead-js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bowhead-js - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

74

dist/main.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.muteExceptions = void 0;
var regex = /{([0-9]+)(|[a-z|]+)?}/g;
var isMuted = true;
const regex = /{([0-9]+)(|[a-z|]+)?}/g;
let isMuted = true;
function muteExceptions(val) {

@@ -10,68 +10,54 @@ isMuted = val;

exports.muteExceptions = muteExceptions;
function format(str) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
function format(str, ...args) {
if (!str) {
return str;
}
return str.replace(regex, function (_, g1, g2) {
var payload = g2 ? g2.substr(1) : '';
var idx = parseInt(g1, 10);
if (isNaN(idx)) {
return str.replace(regex, (_, g1, g2) => {
const payload = g2 ? g2.substr(1) : '';
const idx = parseInt(g1, 10);
if (Number.isNaN(idx)) {
if (isMuted) {
return g1 + " is NaN";
return `${g1} is NaN`;
}
else {
throw new Error("Invalid number in string \"" + str + "\"");
}
throw new Error(`Invalid number in string "${str}"`);
}
if (idx < 0 || idx >= args.length) {
if (isMuted) {
return "<" + idx + " is out of range>";
return `<${idx} is out of range>`;
}
else {
throw new Error("Index out of range in string \"" + str + "\"");
}
throw new Error(`Index out of range in string "${str}"`);
}
var input = args[idx]
? args[idx].toString()
: '';
var payloadStrings = payload.split('|');
var funcName = payloadStrings[0];
var extraParams = payloadStrings.slice(1);
const input = args[idx];
const inputString = `${input}`;
const payloadStrings = payload.split('|');
const funcName = payloadStrings[0];
const extraParams = payloadStrings.slice(1);
if (funcName) {
switch (funcName) {
case 'lowercase':
input = input.toLowerCase();
break;
return inputString.toLowerCase();
case 'uppercase': {
input = input.toUpperCase();
break;
return inputString.toUpperCase();
}
case 'capitalized': {
if (input) {
input = input.charAt(0).toUpperCase() + input.substr(1);
if (inputString) {
return inputString.charAt(0).toUpperCase() + inputString.substr(1);
}
break;
return inputString;
}
case 'countable': {
var inputNum = parseInt(input, 10);
if (!isNaN(inputNum)) {
if (inputNum === 1) {
input = extraParams[0] || '';
}
else {
input = extraParams[1] || extraParams[0] || '';
}
const inputNum = typeof input === 'number' ? input : -1;
if (inputNum === 1) {
return extraParams[0] || '';
}
break;
else if (inputNum >= 0) {
return extraParams[1] || extraParams[0] || '';
}
return inputString;
}
default:
input = input + "|" + funcName;
break;
return `${input}|${funcName}`;
}
}
return input;
return inputString;
});

@@ -78,0 +64,0 @@ }

{
"name": "bowhead-js",
"version": "4.0.0",
"version": "5.0.0",
"description": "Tiny string interpolation library",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"author": "Mgen (https://github.com/mgenware)",
"author": "Mgenware (https://github.com/mgenware)",
"homepage": "https://github.com/mgenware/bowhead-js",

@@ -19,10 +19,4 @@ "bugs": "https://github.com/mgenware/bowhead-js/issues",

"scripts": {
"test": "yarn run clean && yarn run compile && yarn run lint && yarn run t",
"t": "mocha dist_tests/*.js",
"build": "cross-env NODE_ENV=production yarn test",
"compile": "tsc -b tests",
"dev": "cross-env NODE_ENV=development yarn run clean && tsc -b tests -w",
"prepublishOnly": "yarn run test",
"lint": "eslint --max-warnings 0 --ext .ts src/ tests/",
"clean": "del-cli dist && del-cli dist_tests"
"r": "daizong",
"test": "daizong build"
},

@@ -35,2 +29,3 @@ "engines": {

"/dist/**/*.ts",
"/dist/**/*.css",
"/dist/**/*.map"

@@ -40,9 +35,11 @@ ],

"@types/mocha": "^8.0.3",
"@types/node": "^14.14.6",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"cross-env": "^7.0.2",
"del-cli": "^3.0.1",
"eslint": "^7.12.1",
"mocha": "^8.2.0",
"@types/node": "^14.14.7",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"daizong": "^0.11.0",
"eslint": "^7.13.0",
"eslint-config-airbnb-typescript-lite": "^12.0.0",
"eslint-plugin-import": "^2.22.1",
"mocha": "^8.2.1",
"source-map-support": "^0.5.19",
"typescript": "^4.0.5"

@@ -49,0 +46,0 @@ },

@@ -28,8 +28,8 @@ # bowhead-js

// Plurals.
format('{0|countable|fish|fishes}', '1'); // 'fish';
format('{0|countable|fish|fishes}', '2'); // 'fishes'
format('{0|countable|fish|fishes}', '0'); // 'fishes'
format('{0} {0|countable|fish|fishes}', '1'); // '1 fish';
format('{0} {0|countable|fish|fishes}', '2'); // '2 fishes'
format('{0} {0|countable|fish|fishes}', '0'); // '0 fishes'
// "deer" is both singular and plural.
format('{0|countable|deer}', '1'); // 'deer'
format('{0|countable|deer}', '2'); // 'deer'
format('{0} {0|countable|deer}', '1'); // '1 deer'
format('{0} {0|countable|deer}', '2'); // '2 deer'
```

@@ -36,0 +36,0 @@

Sorry, the diff of this file is not supported yet

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