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.1.15 to 1.0.0

_README.md

39

package.json
{
"name": "a-toolbox",
"version": "0.1.15",
"version": "1.0.0",
"description": "javascript lightweight basic tools",
"main": "index.js",
"directories": {
"test": "test"
},
"devDependencies": {
"faker": "^x",
"tap": "^x"
"babel": "^6.x",
"babel-core": "^6.x",
"babel-preset-env": "^1.6.x",
"babel-preset-es2015": "^6.x",
"babelify": "^8.x",
"browserify": "^14.x",
"fs-extra": "^5.x",
"gulp": "^3.x",
"gulp-buffer": "0.0.x",
"gulp-clean": "^0.3.x",
"gulp-sourcemaps": "^2.6.x",
"ink-docstrap": "^1.x",
"standard": "^10.x",
"tap": "^10.x",
"vinyl-source-stream": "^1.x"
},
"engines": {
"node": ">= 4"
"node": ">=6"
},
"scripts": {
"test": "echo 'TODO tap test/*.js'"
"test": "standard && tap test/tdd.js",
"test-cov": "standard && tap test/tdd.js --cov",
"build": "gulp",
"clean": "gulp clean",
"doxdox": "mkdir -p doc; doxdox './src/*.js' --layout markdown --output ./doc/README.md",
"jsdoc": "jsdoc -c jsdoc.json -t ./node_modules/ink-docstrap/template -R README.md src/*.js"
},
"standard": {
"ignore": [
"test/",
"src/_old/"
]
},
"repository": {

@@ -25,2 +46,2 @@ "type": "git",

"license": "MIT"
}
}
# a-toolbox
[![NPM Version](http://img.shields.io/npm/v/a-toolbox.svg?style=flat)](https://www.npmjs.org/package/a-toolbox)

@@ -6,259 +7,37 @@ [![NPM Downloads](https://img.shields.io/npm/dm/a-toolbox.svg?style=flat)](https://www.npmjs.org/package/a-toolbox)

[![JS Standard Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Code Climate](https://codeclimate.com/github/simone-sanfratello/a-toolbox/badges/gpa.svg)](https://codeclimate.com/github/simone-sanfratello/a-toolbox)
[![Test Coverage](https://codeclimate.com/github/simone-sanfratello/a-toolbox/badges/coverage.svg)](https://codeclimate.com/github/simone-sanfratello/a-toolbox/coverage)
[![NPM](https://nodei.co/npm-dl/a-toolbox.png)](https://nodei.co/npm/a-toolbox/)
javascript lightweight basic tools, zero dependecies
Javascript isomorphic lightweight tools
## Purpose
> "This is my rifle. There are many others like it, but this one is mine."
## Npm Installation
## Install
````bash
npm i a-toolbox --save
````
npm install a-toolbox
````
## Tools on Node.js
## API
```js
documentation in progress
var tools = require('a-toolbox.js');
## Changelog
```
v. 1.0.0
## Tools on Browser
- general review
- modular loader
- browser version
```html
---
<script src="https://raw.githubusercontent.com/simone-sanfratello/a-toolbox/master/main.js"></script>
## TODO
```
- [ ] doc (readme, api)
- [ ] tdd via tollo
- [ ] keywords in github and package.json
## Tools
---
**NOTE: missing documentation or obsolete**
#### tasks async manage
```js
var _tasks = new tools.tasks(function () {
console.log('well done');
});
var _asyncOperationTimeout = [ 500, 1000, 200, 1500, 100];
for(var i in _asyncOperationTimeout) {
_tasks.todo('task#' + i);
}
for(var i in _asyncOperationTimeout) {
setTimeout(function(i){
return function() {
console.log('done task #', i);
_tasks.done('task#' + i);
};
}(i), _asyncOperationTimeout[i]);
}
//>done task # 4
//>done task # 2
//>done task # 0
//>done task # 1
//>done task # 3
//>well done
```
#### object merge
```js
var _merge = {a: 1, b: 2};
console.log('to merge', _merge);
tools.object.merge(_merge, {a: 4, c: { d: 8, e: 9}});
console.log('merged', _merge);
//>to merge { a: 1, b: 2 }
//>merged { a: 4, b: 2, c: { d: 8, e: 9 } }
```
#### object clone
```js
var _clone = {a: {7: 6, k: 'a'}, b: 2};
console.log('clone', tools.object.clone(_clone));
//>clone {a: {7: 6, k: 'a'}, b: 2}
```
#### random
```js
console.log('random number from 1 to 100:', tools.random.number(1, 100));
//>random number from 1 to 100: 14
console.log('random string of 8 chars, default set:', tools.random.string(8));
//>random string of 8 chars, default set: dcglhcvr
var _hex = '0123456789abcdef';
console.log('random string of 16 chars, custom set (hex)', _hex, ':', tools.random.string(16, _hex));
//>random string of 16 chars, custom set (hex) 0123456789abcdef : b4a61c1af5360fd4
```
#### string template
Replace marker in template string with provided object data
```js
var data = {
name: 'Alice',
year: 2014,
color: 'yellow'
};
var str = '<div>My name is {name} I was born in {year} and my favourite color is {color}</div>{nothing}';
console.log('template:', tools.string.template(str, data));
//> template: <div>My name is Alice I was born in 2014 and my favourite color is yellow</div>{nothing}
```
#### 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
```
#### string replaceAll
```js
console.log(tools.string.replaceAll("no replace all in js native code that replace all the replace", ' ', '_'));
//> no_replace_all_in_js_native_code_that_replace_all_the_replace
```
#### array remove
```js
var _array = ['very', 'annoying', 'remove', 'elements', 'in', 'js', 'arrays'];
tools.array.remove(_array, 'very');
tools.array.remove(_array, 'annoying');
console.log(_array);
//>[ 'remove', 'elements', 'in', 'js', 'arrays' ]
```
#### array removeAt
```js
tools.array.removeAt(_array, 4);
console.log(_array);
//>[ 'remove', 'elements', 'in', 'arrays' ]
```
#### array first and last
```js
console.log('last element is', tools.array.last(_array));
//>last element is js
console.log('first element is', tools.array.first(_array));
//>first element is remove
```
#### array contains
```js
console.log('contains js?', tools.array.contains(_array, 'js'));
//>contains js? true
console.log('contains ruby?', tools.array.contains(_array, 'ruby'));
//>contains ruby? false
```
#### array insert
```js
tools.array.insert(_array, 0, 'something');
console.log('inserted something', _array);
//>inserted something [ 'something', 'remove', 'elements', 'in', 'js' ]
```
#### array get random element
```js
console.log('get random element:', tools.array.randomElement(_array));
//>get random element element: in
```
#### array concat
```js
console.log('concat more arrays', tools.array.concat(_array, [0,1,2,3], ['a','b','c']));
//>concat more arrays [ 'something',
//> 'remove',
//> 'elements',
//> 'in',
//> 'js',
//> 0,
//> 1,
//> 2,
//> 3,
//> 'a',
//> 'b',
//> 'c' ]
```
#### array empty
When you need to keep references
```js
tools.array.empty(_array);
console.log('empty it', _array);
//>empty it []
```
## License

@@ -268,3 +47,3 @@

Copyright (c) 2015-2017 Simone Sanfratello
Copyright (c) 2015-2018, [braces lab](https://braceslab.com)

@@ -271,0 +50,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -1,11 +0,22 @@

'use strict'
const tools = require('../index')
const samples = {
data: { a: { a1: 1, a2: 2 }, b: 3 }
const tester = require('../').tester
tester.start = async function () {
// console.log('start')
}
let _flat = tools.object.flat(samples.data)
let _raise = tools.object.raise(_flat)
tester.end = async function () {
// console.log('end')
}
console.log(_flat, _raise)
tester.bulk(require('./modules/fs.js'))
tester.bulk(require('./modules/array.js'))
tester.bulk(require('./modules/object.js'))
tester.bulk(require('./modules/hash.js'))
tester.bulk(require('./modules/string.js'))
tester.bulk(require('./modules/random.js'))
tester.bulk(require('./modules/sys.js'))
tester.bulk(require('./modules/task.js'))
tester.bulk(require('./modules/time.js'))
tester.run()
- bower
- browser version != nodejs version
- modular load
- api doc
- jsdoc generate
- tdd
- keywords
- readme
+ no dependencies
+ written in unsleepy night of my newborn daughter Alice
v 1.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