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

qiao-config

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiao-config - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

test/config.js

93

lib/qiao-config.js

@@ -10,11 +10,34 @@ 'use strict';

/**
* c
* c('key', value);
* c('key');
* c('key', null);
* clear
*/
exports.c = function(key, value){
exports.clear = function(){
writeFile('');
};
/**
* all
*/
exports.all = function(){
var json;
try{
var jsonStr = readFile();
json = JSON.parse(jsonStr);
}catch(e){
json = {};
}
return json;
};
/**
* config
* config('key', value);
* config('key');
* config('key', null);
*/
exports.config = function(key, value){
// remove
if(value === null){
exports.del(key);
del(key);
return;

@@ -25,16 +48,13 @@ }

if(typeof value == 'undefined'){
return exports.get(key);
return get(key);
}
// set
exports.set(key, value);
set(key, value);
};
/**
* get
* key
*/
exports.get = function(key){
// get
function get(key){
if(typeof key == 'undefined'){
console.log('qiao-config:set, need key');
console.log('qiao-config:get, need key');
return;

@@ -53,10 +73,6 @@ }

return json[key];
};
}
/**
* set
* key
* value
*/
exports.set = function(key, value){
// set
function set(key, value){
if(typeof key == 'undefined'){

@@ -82,8 +98,6 @@ console.log('qiao-config:set, need key');

}
};
}
/**
*
*/
exports.del = function(key){
// del
function del(key){
if(typeof key == 'undefined'){

@@ -94,3 +108,3 @@ console.log('qiao-config:del, need key');

var v = exports.get(key);
var v = get(key);
if(!v) return;

@@ -106,27 +120,4 @@

}
};
}
/**
* all
*/
exports.all = function(){
var json;
try{
var jsonStr = readFile();
json = JSON.parse(jsonStr);
}catch(e){
json = {};
}
return json;
};
/**
* clear
*/
exports.clear = function(){
writeFile('');
};
// write file

@@ -133,0 +124,0 @@ function writeFile(data){

{
"name": "qiao-config",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "json config to local file",

# qiao-config
json config to local file
## donate
[http://uikoo9.com/donate](http://uikoo9.com/donate)
## api

@@ -24,3 +27,3 @@ ### all

### c
### config
```javascript

@@ -32,11 +35,11 @@ 'use strict';

// set
q.c('test', 'hello');
q.config('test', 'hello');
console.log(q.all());
// get
var s = q.c('test');
var s = q.config('test');
console.log(s);
// del
q.c('test', null);
q.config('test', null);
console.log(q.all());

@@ -46,2 +49,5 @@ ```

## version
### 0.0.3.20201105
1. c --> config
### 0.0.2.20200901

@@ -57,2 +63,2 @@ 1. del ok

4. all ok
5. clear ok
5. clear ok
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