🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

base-io

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-io - npm Package Compare versions

Comparing version

to
2.0.0

43

package.json
{
"name": "base-io",
"version": "1.0.3",
"description": "Easy creation of a basis module.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/negezor/base-io.git"
},
"keywords": [
"easy",
"create",
"structure",
"module",
"node",
"organization"
],
"author": "https://vk.com/id195624402",
"license": "MIT",
"bugs": {
"url": "https://github.com/negezor/base-io/issues"
},
"homepage": "https://github.com/negezor/base-io#readme"
"name": "base-io",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/deprecate-holder.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/deprecate-holder/issues"
},
"homepage": "https://github.com/npm/deprecate-holder#readme",
"dependencies": {}
}

@@ -1,164 +0,5 @@

# BASE-IO
> Добавление в прототип из файлов, наследование, EventEmitter, создание "цепочек"
# Deprecated Package
Позволяет легко создавать структуры модуля разделяя его по файлам и не только
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
[![NPM version](https://img.shields.io/npm/v/base-io.svg)](https://www.npmjs.com/package/base-io)
[![NPM downloads](https://img.shields.io/npm/dt/base-io.svg)](https://www.npmjs.com/package/base-io)
## Инициализация / Начало работы
### Установка модуля
```shell
npm install base-io --save
```
### Инициализация одного экземпляра
```javascript
'use strict';
const base = new (require('base-io'));
```
### Импорт конструктора для расширения
```javascript
base.import(function(){...});
/* Или */
base.import(class Example {
constructor () {...}
});
```
### Экспорт готового конструктора
```javascript
base.export(); // -> object
```
### Наследование объектов
Наследует все свойства объекта
```javascript
base.extend({...});
```
Наследовать EventEmitter
```javascript
base.emitter();
```
### Наследование из файлов
#### Установка пути поиска
Установка пути для поиска директорий, необходимо для `.scan()`
Не обязательно из текущий директории
```javascript
base.root(__dirname);
```
#### Директории с расширением прототипа
Необходимо передать название директории с файлами
Подгружает файлы с расширением .js вытаскивая из них объекты
Принимает `string` или `array`
```javascript
base.scan([
'primary',
'middleware'
]);
/* Или */
base.scan('primary');
base.scan('middleware');
```
Структура папок для примера выше
```
- module
+ primary
+ middleware
```
Пример файлов в любой из этих папок
Контекст выполнения что и в основном классе
```javascript
/* primary/random.js */
exports.getRandom = function(){
return Math.random();
}
/* primary/time.js */
exports.getTimestamp = function(){
return Date.now();
};
/* middleware/test.js */
exports.test = function(){
console.log(this.getTimestamp(),this.getRandom());
};
```
### Создание "цепочек"
Установка специального метода для создания цепочки c привязкой контекста `_properties`
```javascript
base.change();
```
Пример дальнейшего использования
```javascript
/* module/index.js */
'use strict';
const base = new (require('base-io'));
base
.import(function(){
this.name = 'Example';
this.version = 1;
this._properties('foo',this.chain);
})
.root(__dirname)
.scan('main')
.change();
module.exports = base.export();
/* module/main/chain.js */
'use strict';
exports.chain = [];
const add = (way,handler) => {
exports.chain.push({
way: way,
handler: handler
});
};
add('baz',function(){
console.log(this.name);
});
add('bar.quux',function(){
console.log(this.version);
});
/* app.js */
'use strict';
var chain = new (require('./module'));
chain.foo.baz();
// Console: Example
chain.foo.bar.quux();
// Console: 1
```
Структура директорий примера:
```
- module
- main
chain.js
index.js
app.js
```
Please contact support@npmjs.com if you have questions about this package.