Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
stringman-utils
Advanced tools
A collection of utility functions for string manipulation, unit conversion, precision math, and more.
Stringman-Utils is a collection of 320 small helper scripts that can be imported individually. While most of the functionality within the scripts is farily simple to write, the value of using Stringman-Utils is comes from not having to figure out how to write it. Note that TypeScript types are included as well.
Some of the functionality provided:
Note that any conversion modules have the option to return a string instead of a number. This is to enable extended numeric values beyond the normal constraints of JavaScript. JavaScript limits decimals to 16 digits before it begins to return a rounded result or exponential notation. Passing the optional arg for a string return in the conversion modules will allow you to get returned strings with 30 places of precision on either side of the decimal!
example:
9 * 1111111111111111; // 10000000000000000 (it will round)
precisionMathMultiply(9, 1111111111111111, true); // '9999999999999999' (it will not round)
9 / 1111111111111111; // 8.100000000000001e-15 (it will return exponentional notation)
precisionMathDivide(9, 1111111111111111); // '0.0000000000000081' (it will return a regular float as a string)
This is useful when using the conversion functions if you need extreme accuracy and precision. The usage of Big.js also means that the functions are not prone to JavaScript's weird/inaccurate behavior sometimes experienced with floating point math.
npm i stringman-utils
You can view this on npm here.
Utility functions can be imported individually and usage couldn't be more straightforward.
Example:
import { whitespaceRemoveBreaks } from 'stringman-utils';
// or
const whitespaceRemoveBreaks = require('stringman-utils').whitespaceRemoveBreaks;
const removed = whitespaceRemoveBreaks('this line\n has a\r dumb amount of\n line breaks');
console.log(removed); // 'this line has a dumb amount of line breaks'
Another example:
import { emailIsValid } from 'stringman-utils';
// or
const emailIsValid = require('stringman-utils').emailIsValid;
const valid = emailIsValid('test@test.me');
const invalid = emailIsValid('test-test.me');
console.log(valid); // true
console.log(invalid); // false
Nothing this library does is particularly difficult to do, but it is meant to save you time and headaches.
Need to pull an email address out of a string? Want to see what a value in feet would be in kilometers? Maybe you need to calculate a reading time for a blog? Stringman-Utils can do all of these things for you and much more.
Basically, this library has a lot of regular expressions for string manipulation, do some small css style calculations, and lots of unit conversions. I also exposed the functions inside of the precisionMath
file I use for the unit conversion calculations which you can use for your own math functions. There are plans to grow the feature set in the future.
For a full list of functionality, check the documentation.
Big.js is the only external dependency right now. The reason for using it is to provide mathematical precision seeing that JavaScript tends to perform poorly with floating point values. Big.js helps to correct this issue providing accurate calculations.
This project started as a repo/npm library called "stringman" because it was centered around string manipulation. I decided I didn't like how I had the tests and dev environment setup and wanted to add more to it. Because I'm terrible at naming things, I simply added "Utils" to the end of it because it has grown to basically become a collection of utilities.
whitespace
. Maybe you have a string that might have extra spaces that need to be removed. You can call whitespaceSingleSpace
to do this. If you want to remove line breaks, call whitespaceRemoveBreaks
. You get the idea.Stringman-utils has hundreds of helper functions that can be imported individually so you only have exactly what you need in your bundle. For a complete list, check out the documentation in the link above. Here are just a few more examples of the types of functions available (function names listed to demonstrate naming convention):
distanceMilesToMeters
areaSquareMilesToSquareYards
bracketsSwap
caseCamelCase
colorHexToRgb
dataStorageMbToB
CurrencyUtils
emailIsValid
ipRetrieve
numberConvertToHex
parensRetrieve
passwordBuildRegex
precisionMathMultiply
quotesDoubleToSingle
semverIsValid
speedPercentSpeedOfLight
styleConvertRemToPixels
tempCelciusToKelvin
urlGetDomain
volumeGallonsToLiters
weightTonnesToLbs
whitespaceSingleSpace
wordSpecificWordCount
FAQs
A collection of utility functions for string manipulation, unit conversion, precision math, and more.
The npm package stringman-utils receives a total of 38 weekly downloads. As such, stringman-utils popularity was classified as not popular.
We found that stringman-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.