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

a-toolbox

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-toolbox - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

test.js

27

main.js

@@ -193,6 +193,29 @@

string: {
template: function (data, obj, remove) {
return data.replace(/\{([\w]+)\}/g, function (str, key) {
/**
* replace placeholders inside graph brackets {} with obj dictionary
* ~ES6 template string, but safer
* @param {string} str
* @param {type} obj
* @param {bool} [remove=false] remove missing placeholders from obj
* @returns {unresolved}
*/
template: function (str, obj, remove) {
return str.replace(/\{([\w]+)\}/g, function (str, key) {
return obj[key] ? obj[key] : (remove ? '' : str);
});
},
/**
* trim string
* @see http://google.github.io/closure-library/api/namespace_goog_string.html
* @param {string} str
* @param {?string[]} cuts
* @returns {string}
*/
trim: function(str, cuts) {
if(!cuts)
return str.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
else {
var _cuts = cuts.join();
return str.replace(new RegExp('^[' + _cuts + ']+|[' + _cuts + ']+$', 'gm'), '');
}
}

@@ -199,0 +222,0 @@ }

10

package.json
{
"name": "a-toolbox",
"version": "0.0.8",
"version": "0.0.9",
"description": "lightweight tools",

@@ -17,7 +17,7 @@ "keywords": ["tools", "lib", "misc", "toolbox", "array", "task", "random"],

"scripts": {
"test": "node test.js"
"test": "istanbul cover test.js -x test.js"
},
"files": ["main.js"],
"main": "main",
"dependencies": { }
"tonicExampleFilename": "test.js",
"files": ["main.js", "test.js"],
"main": "main"
}

@@ -116,2 +116,14 @@ # a-toolbox

#### string trim
Trim string using custom chars
```js
var str = '({cut these silly brackets please)}';
console.log('trim:', tools.string.trim(str, ['{','}','(',')']));
//> trim: cut these silly brackets please
```
#### replaceAll in String prototype

@@ -118,0 +130,0 @@

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