# unpack-easy

> 粘连包两种解决方案

Latest version **0.0.1** (published 2016-04-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install unpack-easy
pnpm add unpack-easy
yarn add unpack-easy
bun add unpack-easy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2016-04-29 |
| First published | 2016-04-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | baiguangan |
| Maintainers | adorkable |
| Keywords | 粘连包, Buffer |

## Links

- npm: https://www.npmjs.com/package/unpack-easy
- npm.io page: https://npm.io/package/unpack-easy

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2016-04-29

## README

## unpack-easy ![NPM version](https://img.shields.io/npm/v/unpack-easy.svg?style=flat)

粘连包两种解决方案

### Installation
```bash
$ npm install unpack-easy
```

### Example
```js
var unpackEasy = require('unpack-easy');

    服务端

var net = require('net');

var unpackEasy = require('unpack-easy');


var client = net.createServer(function(c) { // 'connection' 监听器
  console.log('服务器已连接');
  c.on('end', function() {
    console.log('服务器已断开');
  });


  c.on('data', function(data) {
    //resolvePackageByEndTag(data, handlerFunc, [0xfd, 0xff]);
    //resolvePackageByLengthTag(data, handlerFunc, 1);

    //g.resolvePackageByLengthTag(data, handlerFunc, 1)
    unpackEasy.resolvePackageByEndTag.call(c, data,handlerFunc, [0x5]);    //通过结尾标识的方法必须通过这种方式
    unpackEasy.resolvePackageByLengthTag(data, handlerFunc, 1);    //通过包头加长度的方式不必要，前提是只有一个socket通道,所以建议都绑定一下作用域

  });

});
client.listen(1111, function() { // 'listening' 监听器
  console.log('服务器已绑定');
});

function handlerFunc(d) {
  console.log(d)
}

    客户端

var net = require('net');
var client = net.connect({port: 1111},
  function() { //'connect' 监听器

      client.write(new Buffer([1,1,1,1,1,1,1,1,0x5,1,1,1,1,1,1,1,1]));
      client.write(new Buffer([1,1,1,1,1,1,1,1,1,0x5,1,1,1,1,1,1,1]));
      //client.write(new Buffer([0x0, 0x1,08]));

  });

client.on('end', function() {
  console.log('客户端断开连接');
});


```

### API

- unpack-easy.resolvePackageByEndTag()
- unpack-easy.resolvePackageByLengthTag()

### Contributing
- Fork this Repo first
- Clone your Repo
- Install dependencies by `$ npm install`
- Checkout a feature branch
- Feel free to add your features
- Make sure your features are fully tested
- Publish your local branch, Open a pull request
- Enjoy hacking <3

### ISC license
Copyright (c) 2016 baiguangan

---

---
_Source: https://npm.io/package/unpack-easy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
