buffer-codec
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -209,2 +209,3 @@ (function() { | ||
options || (options = {}); | ||
this.options = options; | ||
if (options.buffer) { | ||
@@ -223,2 +224,3 @@ if (options.buffer === true) { | ||
options || (options = {}); | ||
this.options = options; | ||
if (isBuffer(value)) { | ||
@@ -225,0 +227,0 @@ return this.decodeBuffer(value, options.bufferStart, options.bufferEnd, options.bufferEncoding); |
@@ -112,2 +112,16 @@ (function() { | ||
HexCodec.prototype._encodeBuffer = function(data, destBuffer, offset, encoding) { | ||
var length; | ||
offset = Number(offset) || 0; | ||
length = data.length; | ||
if (length % 2 !== 0) { | ||
throw new InvalidFormatError('invalid hex string.'); | ||
} | ||
length = length >> 1; | ||
if (isBuffer(destBuffer)) { | ||
length = destBuffer.write(data, offset, length, 'hex'); | ||
} | ||
return length; | ||
}; | ||
HexCodec.prototype._encodeBuffer2 = function(data, destBuffer, offset, encoding) { | ||
var byte, i, length; | ||
@@ -139,2 +153,6 @@ offset = Number(offset) || 0; | ||
HexCodec.prototype._decodeBuffer = function(buf, start, end) { | ||
return buf.toString('hex', start, end); | ||
}; | ||
HexCodec.prototype._decodeBuffer2 = function(buf, start, end) { | ||
var len, result; | ||
@@ -141,0 +159,0 @@ len = buf.length; |
{ | ||
"name": "buffer-codec", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "add the codec ability to abstract-nosql database.", | ||
@@ -12,2 +12,3 @@ "homepage": "https://github.com/snowyu/node-buffer-codec", | ||
"test", | ||
"src", | ||
"lib" | ||
@@ -65,8 +66,3 @@ ], | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/snowyu/node-buffer-codec/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -73,0 +69,0 @@ "url": "https://github.com/snowyu/node-buffer-codec/issues" |
@@ -1,7 +0,3 @@ | ||
# AbstractCodec | ||
# AbstractCodec [![Build Status](https://secure.travis-ci.org/snowyu/node-buffer-codec.png?branch=master)](http://travis-ci.org/snowyu/node-buffer-codec) [![npm](https://img.shields.io/npm/v/buffer-codec.svg)](https://npmjs.org/package/buffer-codec) [![downloads](https://img.shields.io/npm/dm/buffer-codec.svg)](https://npmjs.org/package/buffer-codec) [![license](https://img.shields.io/npm/l/buffer-codec.svg)](https://npmjs.org/package/buffer-codec) | ||
[![Build Status](https://secure.travis-ci.org/snowyu/node-buffer-codec.png?branch=master)](http://travis-ci.org/snowyu/node-buffer-codec) | ||
[![NPM](https://nodei.co/npm/buffer-codec.png?stars&downloads&downloadRank)](https://nodei.co/npm/buffer-codec/) | ||
Add the String/Buffer codec to the [abstract-nosql](https://github.com/snowyu/abstract-nosql) database. | ||
@@ -8,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93345
16
866
140