Socket
Socket
Sign inDemoInstall

libs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libs - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

test/format.js

25

lib/libs/format.js

@@ -1,5 +0,11 @@

function fileSize(_bytes) {
}
var _df = require('dateformat');
/**
* Returns a string in currency format of the provided number
* and symbol.
*
* @param {Number} _num
* @param {String} _symbol
* @api public
*/
function currency(_num, _symbol) {

@@ -12,2 +18,9 @@ if(_symbol === undefined)

/**
* Returns a string of a number with the given presicion.
*
* @param {Number} _num
* @param {int} _precision
* @api public
*/
function decimal(_num, _precision) {

@@ -30,2 +43,8 @@

function fileSize(_bytes) {
}
exports.fileSize = fileSize;

@@ -32,0 +51,0 @@ exports.currency = currency;

@@ -1,2 +0,8 @@

function random(_length) {
/**
* Generates a random number of the provided length
*
* @param {int} _length
* @api public
*/
function random(_length) {

@@ -17,2 +23,9 @@ var string_length = _length;

/** Generates a random number between two numbers
*
* @param {int} _min
* @param {int} _max
* @api public
*/
function randomBetween(_min, _max) {

@@ -19,0 +32,0 @@ var max, min;

@@ -7,3 +7,10 @@ var chars_all = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";

/**
* Generates a random string of the provided length, and including only
* the required characters.
*
* @param {int} _string_length
* @param {String} _mode
* @api public
*/
function randomString(_string_length, _mode) {

@@ -32,3 +39,15 @@

function randomKey(_numOfBlocks, _blockLength, _mode) {
/**
* Generates a random key of the provided length, and including only
* the required characters.
* A key is separated by `-`.
* Also has the option to timestamp the resulting string at the begining.
*
* @param {int} _numOfBlocks
* @param {int} _blockLength
* @param {String} _mode
* @param {Boolean} _timestamp
* @api public
*/
function randomKey(_numOfBlocks, _blockLength, _mode, _timestamp) {
var numOfBlocks = _numOfBlocks;

@@ -49,2 +68,5 @@ var blockLength = _blockLength;

if(_timestamp !== undefined && _timestamp === true)
key = new Date().getTime() + '-' + key;
return key;

@@ -51,0 +73,0 @@ }

6

package.json
{
"name" : "libs",
"version" : "0.1.1",
"version" : "0.1.2",
"description" : "utilities for general NodeJS development",

@@ -8,3 +8,5 @@ "url" : "http://oscar-mejia.com",

"directories" : { "test": "./test"},
"dependencies" : {
"dateformat": "1.0.2-1.2.3"
},
"repository" : {

@@ -11,0 +13,0 @@ "type": "git",

@@ -1,52 +0,3 @@

var libs = require('../lib/libs.js');
console.log("Libs Module Test and Basic Usage!\n");
console.log("String Library");
console.log("randomString (chars_all): " + libs.string.randomString(10) );
console.log("randomString (lower_case): " + libs.string.randomString(10, 'lower_case') );
console.log("randomString (upper_case): " + libs.string.randomString(10, 'upper_case') );
console.log("randomString (nums_oly): " + libs.string.randomString(10, 'nums_oly') );
console.log("randomString (especials): " + libs.string.randomString(10, 'especials') );
console.log("randomKey: " + libs.string.randomKey(4,4) );
console.log("randomKey (lower_case): " + libs.string.randomKey(4,4, 'lower_case') );
console.log("randomKey (upper_case): " + libs.string.randomKey(4,4, 'upper_case') );
console.log("randomKey (nums_oly): " + libs.string.randomKey(4,4, 'nums_oly') );
console.log("randomKey (especials): " + libs.string.randomKey(4,4, 'especials') );
console.log("\n");
console.log("Number Library");
console.log("randomNumber (0): " + libs.number.random(0) );
console.log("randomNumber (1): " + libs.number.random(1) );
console.log("randomNumber (2): " + libs.number.random(2) );
console.log("randomNumber (3): " + libs.number.random(3) );
console.log("randomNumber (4): " + libs.number.random(4) );
console.log("randomNumber (5): " + libs.number.random(5) );
console.log("randomNumber (10): " + libs.number.random(10) );
console.log("randomNumber (20): " + libs.number.random(20) );
console.log("randomBetween 11, 33: " + libs.number.randomBetween(11, 33) );
console.log("randomBetween 0, 10: " + libs.number.randomBetween(0, 10) );
console.log("randomBetween 2, 5: " + libs.number.randomBetween(2, 5) );
console.log("\n");
console.log("Format Library");
console.log("decimal: " + libs.format.decimal() );
console.log("decimal: " + libs.format.decimal(undefined,2) );
console.log("decimal: " + libs.format.decimal(null,3) );
console.log("decimal: " + libs.format.decimal(32.09876, 3) );
console.log("decimal: " + libs.format.decimal(-32.09876, 3) );
console.log("currency: " + libs.format.currency(-132.09876) );
console.log("currency: " + libs.format.currency(100) );
console.log("currency: " + libs.format.currency(0) );
console.log("currency: " + libs.format.currency(0, '$ ') );
console.log("currency: " + libs.format.currency(100.990992893, 'U$') );
console.log("\n");
require('./format.js');
require('./string.js');
require('./number.js');
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