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.1.0 to 1.1.1

doc/API.md

10

fs.js

@@ -11,3 +11,3 @@ const nativeFs = require('fs')

* @method tools.fs.exists
* @param {String} path (filePath) file path
* @param {string} path (filePath) file path
* @return {Promise.<boolean>} true if file exists - and it's a file

@@ -41,6 +41,6 @@ * https://nodejs.org/api/fs.html#fs_fs_exists_path_callback

* @method tools.fs.touch
* @param {String} path (filePath) file path
* @param {string} path (filePath) file path
* @return {Promise.<void>}
* @test.case '/tmp/touch-me'
* @test.case '/none' ! new Error('EACCES')
* @test.case '/tmp/touch-me'
* @test.assert async (result, input, output, sandbox) => {

@@ -74,4 +74,4 @@ * if(!await tester.assert.equal(result, input, output, sandbox)) {

* @method tools.fs.unlink
* @param {String} path (filePath) file path
* @param {boolean} [safe=true]
* @param {string} path (filePath) file path
* @param {boolean} [safe=true] if safe do not throw exception
* @return {Promise.<void>}

@@ -78,0 +78,0 @@ * @test.arrange async function(input, sandbox) {

{
"opts": {
"destination": "./doc/"
"destination": "./doc/jsdoc/"
},

@@ -5,0 +5,0 @@ "plugins": [

{
"name": "a-toolbox",
"version": "1.1.0",
"description": "javascript lightweight basic tools",
"version": "1.1.1",
"description": "javascript lightweight basic tools, zero dependecies, isomorphic",
"main": "index.js",

@@ -31,3 +31,3 @@ "devDependencies": {

"clean": "gulp clean",
"doxdox": "mkdir -p doc; doxdox './src/*.js' --layout markdown --output ./doc/README.md",
"doxdox": "mkdir -p doc/doxdox; 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"

@@ -34,0 +34,0 @@ },

@@ -8,3 +8,3 @@ # a-toolbox

javascript lightweight basic tools, zero dependecies
javascript lightweight basic tools, zero dependecies, isomorphic

@@ -21,2 +21,28 @@ ## Purpose

## Quick start
```js
const tools = require('a-toolbox');
tools.string.trim('({cut these brackets please)}', ['{', '}', '(', ')'])
// > 'cut these brackets please'
```
### On browser
<script src="node_modules/a-toolbox/dist/atoolbox.min.js"></script>
<script>
var data = {
name: 'Alice',
year: 2014,
color: 'purple'
};
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 purple</div>{nothing}
</script>
## API

@@ -26,2 +52,104 @@

- [array](#array)
- [fs](#fs)
- [hash](#hash)
- [object](#object)
- [random](#random)
- [string](#string)
- [sys](#sys)
- [task](#task)
- [time](#time)
- [util](#util)
### array
todo
### fs
note: not available on browser
#### fs.exists(path)
- _path_ \<string\> file path
- _return:_ Promise.\<boolean\> true if file exists - and it's a file
replace deprecated fs.exists
_Example_
````js
tools.fs.exists('/tmp/file')
// > true
````
#### fs.touch(path)
- _path_ \<string\> file path
- _return:_ Promise.\<void\>
create an empty file if not exists
_Example_
````js
tools.fs.touch('/tmp/touch-me')
````
#### fs.unlink(path, [safe=true])
- _path_ \<string\> file path
- _[safe=true]_ \<boolean\> safe do not throw exception
- _return:_ Promise.\<void\>
delete file, optionally in safe mode
_Example_
````js
tools.fs.unlink('/tmp/file')
````
### hash
todo
### object
todo
### random
todo
### string
todo
### sys
note: not available on browser
todo
### task
todo
### time
todo
### util
#### util.isSet()
- _return:_ bool
check if ``val`` is setted, means it's not ``null`` or ``undefined``
#### util.onBrowser()
- _return:_ bool
check if you are on browser or not
---
## Changelog

@@ -28,0 +156,0 @@

@@ -11,3 +11,3 @@ const nativeFs = require('fs')

* @method tools.fs.exists
* @param {String} path (filePath) file path
* @param {string} path (filePath) file path
* @return {Promise.<boolean>} true if file exists - and it's a file

@@ -41,6 +41,6 @@ * https://nodejs.org/api/fs.html#fs_fs_exists_path_callback

* @method tools.fs.touch
* @param {String} path (filePath) file path
* @param {string} path (filePath) file path
* @return {Promise.<void>}
* @test.case '/tmp/touch-me'
* @test.case '/none' ! new Error('EACCES')
* @test.case '/tmp/touch-me'
* @test.assert async (result, input, output, sandbox) => {

@@ -74,4 +74,4 @@ * if(!await tester.assert.equal(result, input, output, sandbox)) {

* @method tools.fs.unlink
* @param {String} path (filePath) file path
* @param {boolean} [safe=true]
* @param {string} path (filePath) file path
* @param {boolean} [safe=true] if safe do not throw exception
* @return {Promise.<void>}

@@ -78,0 +78,0 @@ * @test.arrange async function(input, sandbox) {

@@ -47,3 +47,8 @@ /**

} else {
var _cuts = cuts.join()
const _cuts = cuts.map(c => {
if (c === '[' || c === ']') {
return '\\' + c
}
return c
}).join()
return str.replace(new RegExp('^[' + _cuts + ']+|[' + _cuts + ']+$', 'gm'), '')

@@ -50,0 +55,0 @@ }

const util = {
/**
* check if v is setted, means it's not null or undefined
* @param {*} v
*/
isSet: function (v) {
return (typeof v !== 'undefined' && v !== null)
/**
* check if ``val`` is setted, means it's not ``null`` or ``undefined``
* @param {*} val
* @return {bool}
*/
isSet: function (val) {
return (typeof val !== 'undefined' && val !== null)
},
/**
* check if you are on browser or not
* @return {bool}
*/
onBrowser: function () {

@@ -11,0 +16,0 @@ return (typeof window === 'object' && window instanceof Window)

@@ -47,3 +47,8 @@ /**

} else {
var _cuts = cuts.join()
const _cuts = cuts.map(c => {
if (c === '[' || c === ']') {
return '\\' + c
}
return c
}).join()
return str.replace(new RegExp('^[' + _cuts + ']+|[' + _cuts + ']+$', 'gm'), '')

@@ -50,0 +55,0 @@ }

const util = {
/**
* check if v is setted, means it's not null or undefined
* @param {*} v
*/
isSet: function (v) {
return (typeof v !== 'undefined' && v !== null)
/**
* check if ``val`` is setted, means it's not ``null`` or ``undefined``
* @param {*} val
* @return {bool}
*/
isSet: function (val) {
return (typeof val !== 'undefined' && val !== null)
},
/**
* check if you are on browser or not
* @return {bool}
*/
onBrowser: function () {

@@ -11,0 +16,0 @@ return (typeof window === 'object' && window instanceof Window)

Sorry, the diff of this file is too big to display

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