New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

buffer-codec

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer-codec - npm Package Compare versions

Comparing version 1.5.5 to 1.6.0

146

lib/abstract-codec.js
(function() {
var AbstractError, Codec, Errors, InvalidArgumentError, InvalidFormatError, InvalidUtf8Error, NotImplementedError, createError, createObject, inherits, isBuffer, isInheritedFrom, isNumber, isString,
__slice = [].slice;
var AbstractError, Codec, Errors, InvalidArgumentError, InvalidFormatError, InvalidUtf8Error, NotImplementedError, createError, factory, isBuffer, isString;
inherits = require("abstract-object/lib/util/inherits");
factory = require("custom-factory");
isInheritedFrom = require("abstract-object/lib/util/isInheritedFrom");
isNumber = require("abstract-object/lib/util/isNumber");
isString = require("abstract-object/lib/util/isString");
createObject = require("abstract-object/lib/util/createObject");
Errors = require('abstract-object/Error');

@@ -34,4 +27,6 @@

module.exports = Codec = (function() {
var UNSAFE_CHARS, aliases, codecs, escapeString, unescapeString;
var UNSAFE_CHARS, escapeString, unescapeString;
factory(Codec);
UNSAFE_CHARS = '%';

@@ -50,68 +45,11 @@

Codec._codecs = {};
Codec.formatName = function(aName) {
return aName.toLowerCase();
};
Codec._aliases = {};
codecs = Codec._codecs;
aliases = Codec._aliases;
function Codec(aCodecName, aBufferSize) {
var alias, result, vCaller;
if (isNumber(aCodecName)) {
aBufferSize = aCodecName;
aCodecName = null;
} else if (aCodecName instanceof Codec) {
if (aBufferSize > 0) {
aCodecName.init(aBufferSize);
}
return aCodecName;
}
if (!(this instanceof Codec)) {
if (!aCodecName) {
try {
vCaller = arguments.callee.caller;
} catch (_error) {}
if (vCaller) {
while (isInheritedFrom(vCaller, Codec)) {
aCodecName = vCaller;
vCaller = vCaller.caller;
}
if (aCodecName) {
aCodecName = Codec.getNameFromClass(aCodecName);
}
}
if (!aCodecName) {
return;
}
}
aCodecName = aCodecName.toLowerCase();
result = codecs[aCodecName];
if (result == null) {
alias = aCodecName;
aCodecName = Codec.getRealNameFromAlias(alias);
if (aCodecName) {
result = codecs[aCodecName];
}
}
if (result instanceof Codec) {
if (aBufferSize > 0) {
result.init(aBufferSize);
}
} else if (result) {
if (aBufferSize > 0) {
result = Math.max(result, aBufferSize);
}
if (result < 0 || result === NaN) {
result = void 0;
}
result = codecs[aCodecName] = createObject(Codec[aCodecName], result);
}
return result;
} else {
this.init(aBufferSize);
}
return Codec.__super__.constructor.apply(this, arguments);
}
Codec.prototype.init = function(aBufferSize) {
Codec.prototype.initialize = function(aBufferSize) {
if (this._encodeBuffer || aBufferSize > 0) {

@@ -232,3 +170,3 @@ aBufferSize || (aBufferSize = Codec.bufferSize);

len = this.encodeBuffer(buffer, null, 0, encoding);
destBuffer = this.init(len);
destBuffer = this.initialize(len);
len = this.encodeBuffer(buffer, destBuffer, 0, encoding);

@@ -298,64 +236,2 @@ return destBuffer.slice(0, len);

Codec.getNameFromClass = function(aCodecClass) {
var codecName, len;
codecName = aCodecClass.name;
len = codecName.length;
if (!len) {
throw new InvalidArgumentError('the codec(construcor) has no name error.');
}
if (len > 5 && codecName.substring(len - 5).toLowerCase() === 'codec') {
codecName = codecName.substring(0, len - 5);
}
return codecName;
};
Codec.getRealNameFromAlias = function(alias) {
return aliases[alias];
};
Codec.alias = function() {
var aAliases, aCodecClass, alias, codecName, lowerName, _i, _len, _results;
aCodecClass = arguments[0], aAliases = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
codecName = Codec.getNameFromClass(aCodecClass);
lowerName = codecName.toLowerCase();
if (codecs.hasOwnProperty(lowerName)) {
_results = [];
for (_i = 0, _len = aAliases.length; _i < _len; _i++) {
alias = aAliases[_i];
_results.push(aliases[alias] = lowerName);
}
return _results;
}
};
Codec.aliases = Codec.alias;
Codec.register = function(aCodecClass, aParentCodecClass, aBufferSize) {
var codecName, lowerName;
if (aParentCodecClass == null) {
aParentCodecClass = Codec;
}
inherits(aCodecClass, aParentCodecClass);
codecName = Codec.getNameFromClass(aCodecClass);
aCodecClass.prototype.name = codecName;
lowerName = codecName.toLowerCase();
if (isInheritedFrom(aCodecClass, Codec) && !codecs.hasOwnProperty(lowerName)) {
aParentCodecClass[lowerName] = aCodecClass;
if (aParentCodecClass !== Codec) {
Codec[lowerName] = aCodecClass;
}
if (aBufferSize > 0) {
return codecs[lowerName] = aBufferSize;
} else {
return codecs[lowerName] = -1;
}
} else {
return false;
}
};
Codec.unregister = function(aCodecName) {
return delete codecs[aCodecName.toLowerCase()];
};
Codec.escapeString = escapeString = function(aString, aUnSafeChars) {

@@ -362,0 +238,0 @@ var c, result, _i, _len;

15

package.json
{
"name": "buffer-codec",
"version": "1.5.5",
"version": "1.6.0",
"description": "add the codec ability to abstract-nosql database.",

@@ -18,4 +18,8 @@ "homepage": "https://github.com/snowyu/node-buffer-codec",

},
"pre-commit": [
"test"
],
"dependencies": {
"abstract-object": "~1.8.1"
"abstract-object": "~1.8.1",
"custom-factory": "~1.2.3"
},

@@ -29,3 +33,2 @@ "devDependencies": {

"grunt-contrib-coffee": "*",
"grunt-contrib-concat": "*",
"grunt-contrib-copy": "*",

@@ -38,7 +41,5 @@ "grunt-contrib-jshint": "*",

"grunt-release": "*",
"grunt-rev": "*",
"grunt-saucelabs": "*",
"grunt-usemin": "*",
"mocha": "~2.0.1",
"powerbuild": "latest",
"pre-commit": "~1.0.2",
"sinon": "~1.12.2",

@@ -53,2 +54,4 @@ "sinon-chai": "~2.6.0",

"keywords": [
"factory",
"custom-factory",
"buffer",

@@ -55,0 +58,0 @@ "codec",

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