Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Yet another JavaScript utility library with features like string formatting, collections, and more.
WarmseaJS is yet another JavaScript utility library.
WarmseaJS v1.0.0 is designed to be a drop-in replacement of underscore.js with
var _ = warmsea;
executed. It is fully compatible with underscore.js v1.7.0
with two exceptions, .VERSION
and .noConflict()
. Both functions works for
warmsea but underscore.
It provides more feature besides underscore functions, such as:
Install WarmseaJS with NPM:
npm install warmsea
Then, you can use all the APIs from WarmseaJS. For example:
var w = require('warmsea');
var name = 'warmsea';
var msg = w.format('Hello, %s!', name);
console.log(msg); // `Hello, warmsea!` will be printed.
Download WarmseaJS:
Include the JS file with <script>
tag or RequireJS.
When included with <script>
tag, a global namespace warmsea
will be
introduced. Personally, I use _
or w
as a shortcut of warmsea
. You can
use anything else you like, or just use warmsea
. In this README file, w
is
used as the shortcut of warmsea
.
<script src="path/to/warmsea.min.js"></script>
<script>
var _ = warmsea;
...
</script>
require(['warmsea'], function(_) {
...
});
You may need to configure RequireJS before you can require WarmseaJS with it.
Then, you can use all the APIs from WarmseaJS. For example:
var name = 'warmsea';
var msg = w.format('Hello, %s!', name);
console.log(msg); // `Hello, warmsea!` will be printed.
Throws an Error with a specified message.
w.error();
// throw new Error();
w.error('invalid');
// throw new Error('invalid');
w.error('[%s] invalid', (new Date()).toISOString());
// throw new Error('[2014-10-09T11:27:19.158Z] invalid');
// w.error() is powered by w.format(), so format feature is provided.
Throws an Error says "Unimplemented".
w.inArray()
is powered by _.indexOf()
.
w.inArray([1, 2, 3], 2); // Returns true
w.inArray([1, 2, 3], 4); // Returns false
w.sort(list, cmp, context)
is a in-place sort function. It returns list
after it is sorted.
w.sort([-3, -1, 2, 4], function(a, b) {
return w.cmp(a * a, b * b);
});
// Returns [-1, 2, -3, 4]
Almost the same as w.sorted()
except it doesn't change the original array,
but returns a sorted shallow copied one.
Collections module provides two classes: w.Stack
and w.Queue
.
// Create a debugger with the specified name.
var dbg = w.debug('business:account');
// All debuggers are disabled by default.
// Enable a debugger.
w.debug.enable('business:account');
// Enable all debuggers start with "business:".
w.debug.enable('business:*');
// Disable a debugger.
w.debug.disable('business:someName');
// Call a debugger. If it is enabled, it will print the debug message.
// If not, nothing happens.
dbg('Debug Message');
// Debuggers can be enabled or disabled before OR after their creations.
w.debug.enable('*'); // Enable all debuggers.
var dbg1 = w.debug('hello'); // It is enabled.
// Check if a name is enabled.
w.debug.enabled('someName');
w.cmp = function(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
};
Make some properties not enumerable. Only works in ES5.
var obj = {
a: 1,
b: 2
};
w.keys(obj); // Returns ["a", "b"]
w.hideProperties(obj, ['a']);
w.keys(obj); // Returns ["b"]
w.memoizedProperty(obj, name, getter, enumerable=true)
adds a memoized property
to an object.
In ES5, the property is initialized with getter
during the first access, and
then the value is remembered. But in ES4, the property is initialized
immediately.
var obj = {};
w.memoizedProperty(obj, '_date', function() {
return new Date();
}, false);
Random module contains 3 functions: w.randomInt()
, w.randomFloat
, and
randomString()
.
Function | Description |
---|---|
w.randomInt(stop) | Returns an integer in [0, stop) |
w.randomInt(start, stop) | Returns an integer in [start, stop) |
w.randomFloat(stop) | Returns a number in [0, stop) |
w.randomFloat(start, stop) | Returns a number in [start, stop) |
w.randomString(length, allowedChars) | Returns a random string |
// pad
w.pad('hello', 8, '#'); // '###hello'
w.pad(7, 3, 0); // '007'
w.pad('x', 5, 'abc'); // 'abcax'
// format
w.format('Hello, %s!', 'warmsea'); // 'Hello, warmsea!'
w.format('%04d%02d%02d', 2004, 4, 1); // '20040401'
w.format('%x', 255); // 'ff'
w.format('%#X', 255); // '0XFF'
w.format('%+8.2f', 123.456); // ' +123.46'
w.format('%(year)04d-%(month)02d-%(day)02d',
{year: 2004, month: 4, day: 1}); // '2014-04-01'
w.format('To %(action)s, or not to %(action)s.',
{action: 'do'}); // 'To do, or not to do.'
// Multi-line format
var template = function() {
/*!<<<EOD
Hello,
%s!
EOD*/
};
w.format(template, 'warmsea'); // 'Hello,
// ' warmsea!
w.format(function() {
/*<<<EOD;WS-KEEP
Hello,
space!
EOD*/
}); // ' Hello,
// ' space!
// type casting
w.bool(1); // true
w.i('35'); // 35
w.i('0xff'); // 255
w.f('1.35e3'); // 1350
w.str(1.35e3); // '1350'
w.array(); // []
w.array('hello'); // ['hello']
// type testing
w.isNumber(0xff); // true
w.isNumber('0xff'); // false
w.isInt(1); // true
w.isString('0xff'); // true
w.isArray([]); // true
w.isFunction(w.isFunction); // true
w.isPlainObject({'a': '1'}); // true
w.isPlainObject(new Date()); // false
w.isObject(new Date()); // true
w.isObject([]); // true
Here, I use w
as the shortcut of warmsea
.
FAQs
Yet another JavaScript utility library with features like string formatting, collections, and more.
The npm package warmsea receives a total of 1 weekly downloads. As such, warmsea popularity was classified as not popular.
We found that warmsea 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.