Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
fwsp-jsutils
Advanced tools
Readme
Flywheel JS utils is a library of useful JavaScript utilities.
You can install it via NPM:
$ npm -i fwsp-jsutils
const Utils = require('fwsp-jsutils');
let hash = Utils.stringHash('This is a test');
Tests can be found in the specs
folder.
$ npm test
/**
* @name strip
* @summary strips white space characters - except for spaces
* @param {string} str - string to strip characters from
* @return {string} string - without white space characters
*/
static strip(str)
/**
* @name zeroPad
* @summary add preceeding zeros to maintain desired places
* @param {number} num - number to zero pad
* @param {number} places - place digits (length)
* @return {string} string with preceeding zeros
*/
static zeroPad(num, places)
/**
* @name stringHash
* @summary returns a hash value for a supplied string
* @see https://github.com/darkskyapp/string-hash
* @private
* @param {object} str - string to hash
* @return {number} hash - hash value
*/
static stringHash(str)
/**
* @name shortID
* @summary generate a random id composed of alphanumeric characters
* @see https://en.wikipedia.org/wiki/Base36
* @return {string} random string id
*/
static shortID()
/**
* @name UUID
* @summary Pseudo UUID
* @return {string} uuid - unique string
*/
static UUID()
/**
* @name isUUID4
* @summary determine whether a string is a valid UUID
* @param {string} str - possible UUID
* @return {undefined}
*/
static isUUID(str)
/**
* @name isObject
* @summary Determines whether a variable is an object
* @param {object} obj - variable being tested
* @return {boolean} - true if object else false
*/
static isObject(obj)
/**
* @name isArray
* @summary Determines whether a variable is an array
* @param {object} obj - variable being tested
* @return {boolean} - true if array else false
*/
static isArray(obj)
/**
* @name safeJSONParse
* @summary Safe JSON parse
* @private
* @param {string} str - string which will be parsed
* @return {object} obj - parsed object
* Returns undefined if string can't be parsed into an object
*/
static safeJSONStringify(obj)
/**
* @name safeJSONParse
* @summary Safe JSON parse
* @private
* @param {string} str - string which will be parsed
* @return {object} obj - parsed object
* Returns undefined if string can't be parsed into an object
*/
static safeJSONParse(str)
/**
* @name shuffleArray
* @summary Shuffles and array
* @description Uses the Durstenfeld shuffle algorithm
* @param {array} array - to shuffle
* @return {array} array - shuffled array
*/
static shuffleArray(array)
/**
* @name htmlEncode
* @summary Encode HTML text by converting characters to html codes
* @param {string} text - html text to encode
* @return {string} text - encoded html text
*/
static htmlEncode(text)
/**
* @name htmlDecode
* @summary Decode HTML text to original form
* @param {string} text - html text to encode
* @return {string} text - decoded html text
*/
static htmlDecode(text)
/**
* @name md5Hash
* @summary Hashes a key to produce an MD5 hash
* @param {string} key - input key to hash
* @return {string} hash - hashed value
*/
static md5Hash(key)
/**
* @name getGeoDistance
* @summary Get the distance between to lat/lngs
* @notes http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points
* @param {number} lat1 - from lat
* @param {number} lng1 - from lng
* @param {number} lat2 - to lat
* @param {number} lng2 - to lng
* @return {number} value - distance in miles
*/
static getGeoDistance(lat1, lng1, lat2, lng2) {
/**
* @name getRandom
* @summary Returns a random number between 0 (inclusive) and 1 (exclusive)
* @return {number} num - number
*/
static getRandom()
/**
* @name getRandomArbitrary
* @summary Returns a random number between min (inclusive) and max (exclusive)
* @return {number} num - number
*/
static getRandomArbitrary(min, max)
/**
* @name getRandomInt
* @summary Returns a random integer between min (included) and max (excluded)
* @return {number} num - number
*/
static getRandomInt(min, max)
/**
* @name getRandomIntInclusive
* @summary Returns a random integer between min (included) and max (included)
* @return {number} num - number
*/
static getRandomIntInclusive(min, max)
FAQs
JavaScript Utils - useful dev utils
The npm package fwsp-jsutils receives a total of 437 weekly downloads. As such, fwsp-jsutils popularity was classified as not popular.
We found that fwsp-jsutils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.