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

erlang

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erlang - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

decode.js

29

api.js

@@ -1,8 +0,27 @@

// The erlang.js API
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var term_to_binary = require('./term_to_binary');
var encode = require('./encode.js')
var decode = require('./decode.js')
var iolist = require('./iolist.js')
module.exports = { "term_to_binary": term_to_binary.term_to_binary
, "optlist_to_binary": term_to_binary.optlist_to_binary
}
module.exports =
{ term_to_binary : encode
, optlist_to_term : encode.optlist_to_term
, optlist_to_binary: encode.optlist_to_binary
, binary_to_term : decode
, iolist_to_binary : iolist.to_buffer
, iolist_to_buffer : iolist.to_buffer
, iolist_size : iolist.size
}

69

lib.js

@@ -0,5 +1,20 @@

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
exports.VERSION_MAGIC = 131; // 131 83
exports.MAX_INTEGER = (1 << 27) - 1;
exports.MIN_INTEGER = -(1 << 27);
exports.typeOf = typeOf
exports.flatten = flatten
exports.numbers = {} // To be filled in later.
exports.tags = { 'SMALL_INTEGER' : 'a' // 97 61

@@ -29,7 +44,10 @@ , 'INTEGER' : 'b' // 98 62

// Actually these need to be integers to be useful.
Object.keys(exports.tags).forEach(function(key) {
exports.tags[key] = exports.tags[key].charCodeAt(0);
})
// Actually these need to be integers to be useful. And set up a reverse-lookup object.
for (var tag in exports.tags) {
var num = exports.tags[tag].charCodeAt(0)
exports.tags[tag] = num
exports.numbers[num] = tag
}
// Note: using Object.prototype.toString instead of instanceof because it's not working.
function to_s(val) {

@@ -39,26 +57,25 @@ return Object.prototype.toString.apply(val);

typeOf = exports.typeOf = function(value) {
var s = typeof value;
function typeOf(value) {
if (Buffer.isBuffer(value))
return 'buffer'
// Note: using Object.prototype.toString instead of instanceof because it's not working.
if (s === 'object') {
if (value) {
if(to_s(value) === '[object Array]')
s = 'array';
else if(to_s(value) === '[object Buffer]')
s = 'buffer';
else if(typeof Buffer === 'function' && value instanceof Buffer)
s = 'buffer';
} else {
s = 'null';
}
} else if(s === 'function' && to_s(value) === '[object RegExp]') {
return 'regexp';
}
return s;
if (Array.isArray(value))
return 'array'
var s = typeof value
if (s === 'object' && !value)
return 'null'
if(s === 'function' && to_s(value) === '[object RegExp]')
return 'regexp'
return s
}
flatten = exports.flatten = function (ar) {
function flatten(ar) {
return ar.reduce(function(state, elem) {
return state.concat(typeOf(elem) === 'array' ? flatten(elem) : [elem]);
return typeOf(elem) === 'array'
? state.concat(flatten(elem))
: state.concat([elem])
}, [])

@@ -71,3 +88,3 @@ }

, n >> 8 & 0xff
, n >> 0 & 0xff ];
, n >> 0 & 0xff ]
}

@@ -77,3 +94,3 @@

return [ n >> 16 & 0xff
, n >> 0 & 0xff ];
, n >> 0 & 0xff ]
}
{ "name": "erlang"
, "version": "0.2.0"
, "author": { "name": "Iris Couch"
, "email": "jhs@iriscouch.com" }
, "version": "1.0.0"
, "author": { "name": "Jason Smith", "email": "jason.h.smith@gmail.com" }
, "description": "Erlang interoperability with Javascript"

@@ -10,3 +9,13 @@ , "homepage": "http://github.com/iriscouch/erlang.js"

, "engines": [ "node" ]
, "main": "api"
, "main": "./api.js"
, "scripts": { "test" : "tap test/"
}
, "dependencies": { "debug": "~1.0.4"
}
, "devDependencies": { "tap": "~0.4.8"
, "async": "~0.2.10"
, "traceback": "~0.3.1"
}
}

@@ -9,9 +9,2 @@ var sys = require('util')

/* XXX This used to be used however now objects are used to create special types. Keeping for posterity.
// Return the "meat" of a regex, or null if it is not a regex.
function regex_of(val) {
return lib.typeOf(val) === 'regexp' ? val.toString().slice(1, -1) : null;
}
*/
// Use object creation because I don't like object literal syntax to place functions in a namespace.

@@ -28,2 +21,6 @@ var Encoder = function() {

self.null = function() {
return [lib.tags.NIL]
}
self.number = function(x) {

@@ -85,2 +82,5 @@ return is_int(x) ? self.int(x) : self.float(x);

if((tag === 'pid' || tag === 'p') && valType === 'object')
return self.pid(val);
throw new Error("Unknown tag " + tag.toString() + " for value: " + sys.inspect(val));

@@ -109,2 +109,12 @@ }

self.pid = function(x) {
return [
lib.tags.PID,
self.encode(x.node),
lib.uint32(x.id),
lib.uint32(x.serial),
x.creation
];
}
self.buffer = function(x) {

@@ -111,0 +121,0 @@ var result = [lib.tags.BINARY];

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