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 1.2.4 to 1.2.5

TODO.md

185

doc/API.md

@@ -386,1 +386,186 @@ ### array

---
### string
#### string.template(str, obj, [remove=false])
- _str_ \<string\>
- _obj_ \<Object\>
- _[remove=false]_ \<boolean\> remove missing placeholders from obj, default false
- _return:_ string
replace placeholders inside graph brackets {} with obj dictionary\n~ES6 template string without $
_Example_
````js
tools.string.template('hi {name} how are you?', {name: 'Alice'})
// > 'hi Alice how are you?'
````
#### string.trim(str, cuts)
- _str_ \<string\>
- _cuts_ \<Array<string>\>
- _return:_ string
trim string
_Example_
````js
tools.string.trim(' regular trim ')
// > 'regular trim'
````
#### string.replaceAll(str, from, to)
- _str_ \<string\>
- _from_ \<string\>
- _to_ \<string\>
- _return:_ string
_Example_
````js
tools.string.replaceAll('abcadaeafaga', 'a', '')
// > 'bcdefg'
````
#### string.capitalize(str)
- _str_ \<string\>
- _return:_ string
_Example_
````js
tools.string.capitalize('alice')
// > 'Alice'
````
#### string.prependMissing(prefix, str)
- _prefix_ \<string\>
- _str_ \<string\>
- _return:_ string
_Example_
````js
tools.string.prependMissing('miss ', 'Alice')
// > 'miss Alice'
````
---
### random
#### random.rnd(max)
- _max_ \<number\>
- _return:_ number
get random int from 0 to max
_Example_
````js
tools.random.rnd(10)
````
#### random.number(min, max)
- _min_ \<number\>
- _max_ \<number\>
- _return:_ number
get random int from min to max
_Example_
````js
tools.random.number(10, 20)
````
#### random.string([length=8], [set=abcdefghijklmnopqrstuvwxyz])
- _[length=8]_ \<number\>
- _[set=abcdefghijklmnopqrstuvwxyz]_ \<Array\>
- _return:_ string
get random string
_Example_
````js
tools.random.number(8)
````
#### random.hex([length=8])
- _[length=8]_ \<number\>
- _return:_ string
get random hex string
_Example_
````js
tools.random.hex(8)
````
#### random.hash(salt)
- _salt_ \<?string\>
- _return:_ string
get random hash string
_Example_
````js
tools.random.hash()
````
#### random.element(array, not)
- _array_ \<Array<*>\>
- _not_ \<Array<*>\>
- _return:_ * element
get random element from array
_Example_
````js
tools.random.element([1,2,3,4,5])
````
---
### sys
#### sys.isRoot()
- _return:_ bool is root or not
check if running user is root

1

fs.js
const nativeFs = require('fs')
/**
* note: not available on browser
* @namespace tools.fs

@@ -5,0 +6,0 @@ */

2

package.json
{
"name": "a-toolbox",
"version": "1.2.4",
"version": "1.2.5",
"description": "javascript lightweight basic tools, isomorphic",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,2 +12,9 @@ const hash = require('./hash')

* @return {number}
* @test.case 10
* @test.case 100
* @test.case 2
* @test.case 99
* @test.assert async (result, input, output, sandbox) => {
* return result >= 0 && result <= input[0]
* }
*/

@@ -26,2 +33,8 @@ rnd: function (max) {

* @return {number}
* @test.case 10, 20
* @test.case 1, 100
* @test.case 0, 10
* @test.assert async (result, input, output, sandbox) => {
* return result >= input[0] && result <= input[1]
* }
*/

@@ -36,2 +49,3 @@ number: function (min, max) {

},
/**

@@ -43,2 +57,23 @@ * get random string

* @return {string}
* @test.case 8
* @test.case 1, '1234567890'
* @test.case 0
* @test.case -1
* @test.assert async (result, input, output, sandbox) => {
* if(!input[0] && input[0] !== 0) {
* input[0] = 8
* }
* if(!input[1]) {
* input[1] = 'abcdefghijklmnopqrstuvwxyz'
* }
*
* if(result.length !== input[0])
*
* for (let i = 0; i < input[0]; i++) {
* if(input[1].indexOf(result[i]) === -1) {
* return false
* }
* }
* return true
* }
*/

@@ -52,2 +87,3 @@ string: function (length = 8, set = 'abcdefghijklmnopqrstuvwxyz') {

},
/**

@@ -58,2 +94,20 @@ * get random hex string

* @return {string}
* @test.case 8
* @test.case 16
* @test.case 0
* @test.case -1
* @test.assert async (result, input, output, sandbox) => {
* if(!input[0] && input[0] !== 0) {
* input[0] = 8
* }
*
* if(result.length !== input[0])
*
* for (let i = 0; i < input[0]; i++) {
* if('0123456789abcdef'.indexOf(result[i]) === -1) {
* return false
* }
* }
* return true
* }
*/

@@ -63,2 +117,3 @@ hex: function (length = 8) {

},
/**

@@ -69,2 +124,6 @@ * get random hash string

* @return {string}
* @test.case
* @test.assert async (result, input, output, sandbox) => {
* return result.length === 64
* }
*/

@@ -74,8 +133,20 @@ hash: function (salt = '') {

},
/**
* get random element from array
* @method tools.random.hash
* @method tools.random.element
* @param {Array<*>} array
* @param {Array<*>} not
* @return {*} element
* @test.case [1,2,3,4,5]
* @test.case [1,2,3,4,5], 5
* @test.case [1,2,3,4,5], 6
* @test.assert async (result, input, output, sandbox) => {
* if(input[1]) {
* if(result === input[1]) {
* return false
* }
* }
* return input[0].indexOf(result)
* }
*/

@@ -82,0 +153,0 @@ element: function (array, not) {

@@ -68,7 +68,4 @@ # a-toolbox

- [random](#random)
todo
- [string](#string)
todo
- [sys](#sys)
todo
- [task](#task)

@@ -467,4 +464,190 @@ todo

---
### string
#### string.template(str, obj, [remove=false])
- _str_ \<string\>
- _obj_ \<Object\>
- _[remove=false]_ \<boolean\> remove missing placeholders from obj, default false
- _return:_ string
replace placeholders inside graph brackets {} with obj dictionary\n~ES6 template string without $
_Example_
````js
tools.string.template('hi {name} how are you?', {name: 'Alice'})
// > 'hi Alice how are you?'
````
#### string.trim(str, cuts)
- _str_ \<string\>
- _cuts_ \<Array<string>\>
- _return:_ string
trim string
_Example_
````js
tools.string.trim(' regular trim ')
// > 'regular trim'
````
#### string.replaceAll(str, from, to)
- _str_ \<string\>
- _from_ \<string\>
- _to_ \<string\>
- _return:_ string
_Example_
````js
tools.string.replaceAll('abcadaeafaga', 'a', '')
// > 'bcdefg'
````
#### string.capitalize(str)
- _str_ \<string\>
- _return:_ string
_Example_
````js
tools.string.capitalize('alice')
// > 'Alice'
````
#### string.prependMissing(prefix, str)
- _prefix_ \<string\>
- _str_ \<string\>
- _return:_ string
_Example_
````js
tools.string.prependMissing('miss ', 'Alice')
// > 'miss Alice'
````
---
### random
#### random.rnd(max)
- _max_ \<number\>
- _return:_ number
get random int from 0 to max
_Example_
````js
tools.random.rnd(10)
````
#### random.number(min, max)
- _min_ \<number\>
- _max_ \<number\>
- _return:_ number
get random int from min to max
_Example_
````js
tools.random.number(10, 20)
````
#### random.string([length=8], [set=abcdefghijklmnopqrstuvwxyz])
- _[length=8]_ \<number\>
- _[set=abcdefghijklmnopqrstuvwxyz]_ \<Array\>
- _return:_ string
get random string
_Example_
````js
tools.random.number(8)
````
#### random.hex([length=8])
- _[length=8]_ \<number\>
- _return:_ string
get random hex string
_Example_
````js
tools.random.hex(8)
````
#### random.hash(salt)
- _salt_ \<?string\>
- _return:_ string
get random hash string
_Example_
````js
tools.random.hash()
````
#### random.element(array, not)
- _array_ \<Array<*>\>
- _not_ \<Array<*>\>
- _return:_ * element
get random element from array
_Example_
````js
tools.random.element([1,2,3,4,5])
````
---
### sys
note: not available on browser
#### sys.isRoot()
- _return:_ bool is root or not
check if running user is root
---
## Changelog

@@ -474,3 +657,3 @@

- use [hash.js](https://github.com/indutny/hash.js) instead of ``crypto``
- use [hash.js](https://github.com/indutny/hash.js) instead of ``crypto`` (for browser)

@@ -487,5 +670,4 @@ v. 1.0.0

- [ ] doc (readme, api)
- [ ] doc
- [ ] tdd via tollo
- [ ] keywords in github and package.json

@@ -492,0 +674,0 @@ ---

@@ -12,2 +12,9 @@ const hash = require('./hash')

* @return {number}
* @test.case 10
* @test.case 100
* @test.case 2
* @test.case 99
* @test.assert async (result, input, output, sandbox) => {
* return result >= 0 && result <= input[0]
* }
*/

@@ -26,2 +33,8 @@ rnd: function (max) {

* @return {number}
* @test.case 10, 20
* @test.case 1, 100
* @test.case 0, 10
* @test.assert async (result, input, output, sandbox) => {
* return result >= input[0] && result <= input[1]
* }
*/

@@ -36,2 +49,3 @@ number: function (min, max) {

},
/**

@@ -43,2 +57,23 @@ * get random string

* @return {string}
* @test.case 8
* @test.case 1, '1234567890'
* @test.case 0
* @test.case -1
* @test.assert async (result, input, output, sandbox) => {
* if(!input[0] && input[0] !== 0) {
* input[0] = 8
* }
* if(!input[1]) {
* input[1] = 'abcdefghijklmnopqrstuvwxyz'
* }
*
* if(result.length !== input[0])
*
* for (let i = 0; i < input[0]; i++) {
* if(input[1].indexOf(result[i]) === -1) {
* return false
* }
* }
* return true
* }
*/

@@ -52,2 +87,3 @@ string: function (length = 8, set = 'abcdefghijklmnopqrstuvwxyz') {

},
/**

@@ -58,2 +94,20 @@ * get random hex string

* @return {string}
* @test.case 8
* @test.case 16
* @test.case 0
* @test.case -1
* @test.assert async (result, input, output, sandbox) => {
* if(!input[0] && input[0] !== 0) {
* input[0] = 8
* }
*
* if(result.length !== input[0])
*
* for (let i = 0; i < input[0]; i++) {
* if('0123456789abcdef'.indexOf(result[i]) === -1) {
* return false
* }
* }
* return true
* }
*/

@@ -63,2 +117,3 @@ hex: function (length = 8) {

},
/**

@@ -69,2 +124,6 @@ * get random hash string

* @return {string}
* @test.case
* @test.assert async (result, input, output, sandbox) => {
* return result.length === 64
* }
*/

@@ -74,8 +133,20 @@ hash: function (salt = '') {

},
/**
* get random element from array
* @method tools.random.hash
* @method tools.random.element
* @param {Array<*>} array
* @param {Array<*>} not
* @return {*} element
* @test.case [1,2,3,4,5]
* @test.case [1,2,3,4,5], 5
* @test.case [1,2,3,4,5], 6
* @test.assert async (result, input, output, sandbox) => {
* if(input[1]) {
* if(result === input[1]) {
* return false
* }
* }
* return input[0].indexOf(result)
* }
*/

@@ -82,0 +153,0 @@ element: function (array, not) {

@@ -11,3 +11,3 @@ /**

* @param {Object} obj
* @param {boolean} [remove=false] missing placeholders from obj, default false
* @param {boolean} [remove=false] remove missing placeholders from obj, default false
* @return {string}

@@ -36,3 +36,3 @@ *

* @param {string} str
* @param {?string[]} cuts
* @param {Array<string>} cuts
* @return {string}

@@ -39,0 +39,0 @@ *

@@ -19,3 +19,3 @@ const time = require('./time')

* add task
* @param {!String} id
* @param {!string} id
*/

@@ -22,0 +22,0 @@ this.todo = function (id) {

@@ -11,3 +11,3 @@ /**

* @param {Object} obj
* @param {boolean} [remove=false] missing placeholders from obj, default false
* @param {boolean} [remove=false] remove missing placeholders from obj, default false
* @return {string}

@@ -36,3 +36,3 @@ *

* @param {string} str
* @param {?string[]} cuts
* @param {Array<string>} cuts
* @return {string}

@@ -39,0 +39,0 @@ *

/**
* note: not available on browser
* @namespace tools.sys

@@ -3,0 +4,0 @@ */

@@ -19,3 +19,3 @@ const time = require('./time')

* add task
* @param {!String} id
* @param {!string} id
*/

@@ -22,0 +22,0 @@ this.todo = function (id) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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