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

jpacks

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jpacks - npm Package Compare versions

Comparing version 0.6.18 to 0.6.20

12

jpacks.dev.js

@@ -8,4 +8,4 @@ (function (exportName) {

* zswang (http://weibo.com/zswang)
* @version 0.6.18
* @date 2016-03-21
* @version 0.6.20
* @date 2016-04-06
*/

@@ -1128,6 +1128,9 @@ function createSchema() {

*/
function stringBytes(value, options) {
function stringBytes(value, options) {
if (!options.browser && typeof Buffer !== 'undefined') { // NodeJS
return new Buffer(value, options.encoding);
} else {
if (typeof TextEncoder === 'function') {
return Array.from(new TextEncoder(options.encoding).encode(value));
}
return encodeUTF8(value).split('').map(function (item) {

@@ -1176,2 +1179,5 @@ return item.charCodeAt();

}
if (typeof TextDecoder === 'function') {
return new TextDecoder(options.encoding).decode(stringBuffer);
}
return decodeUTF8(String.fromCharCode.apply(String, stringBuffer));

@@ -1178,0 +1184,0 @@ },

@@ -8,4 +8,4 @@ (function (exportName) {

* zswang (http://weibo.com/zswang)
* @version 0.6.18
* @date 2016-03-21
* @version 0.6.20
* @date 2016-04-06
*/

@@ -1065,6 +1065,9 @@ function createSchema() {

*/
function stringBytes(value, options) {
function stringBytes(value, options) {
if (!options.browser && typeof Buffer !== 'undefined') { // NodeJS
return new Buffer(value, options.encoding);
} else {
if (typeof TextEncoder === 'function') {
return Array.from(new TextEncoder(options.encoding).encode(value));
}
return encodeUTF8(value).split('').map(function (item) {

@@ -1113,2 +1116,5 @@ return item.charCodeAt();

}
if (typeof TextDecoder === 'function') {
return new TextDecoder(options.encoding).decode(stringBuffer);
}
return decodeUTF8(String.fromCharCode.apply(String, stringBuffer));

@@ -1115,0 +1121,0 @@ },

@@ -5,3 +5,3 @@ {

"description": "Binary data packing and unpacking.",
"version": "0.6.18",
"version": "0.6.20",
"homepage": "http://github.com/zswang/jpacks",

@@ -8,0 +8,0 @@ "main": "jpacks.js",

@@ -56,2 +56,6 @@ var protobufjs = require('protobufjs');

if (!value && /int64/.test(type.type.name)) { // 空值优化
value = 0;
}
if (type.type.name === 'bytes') {

@@ -273,2 +277,14 @@ result[key] = bytesify(value, options);

```
* @example protobufCreator():int64 from empty string
```js
var _ = jpacks;
var _schema = _.protobuf('package Long; message Value { optional uint64 value = 1; }', 'Long.Value', null);
var buffer = _.pack(_schema, {
value: ''
});
console.log(JSON.stringify(_.unpack(_schema, buffer)));
// > {"value":"0"}
```
'''</example>'''

@@ -275,0 +291,0 @@ */

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