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

primea-objects

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primea-objects - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.nyc_output/08ab503df9a4cef06313a1703dff8f8c.json

88

docs/index.md

@@ -7,17 +7,19 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->

- [FunctionRef][2]
- [ModuleRef][3]
- [getFuncRef][4]
- [Message][5]
- [copy][3]
- [ModuleRef][4]
- [getFuncRef][5]
- [Message][6]
- [getType][7]
##
[index.js:11-18][6]
[index.js:5-10][8]
a cbor decoder for the objects
Type: [Object][7]
Type: [Object][9]
## ID
[index.js:45-60][8]
[index.js:37-52][10]

@@ -32,3 +34,3 @@ an ID

[index.js:65-87][9]
[index.js:57-92][11]

@@ -39,7 +41,15 @@ A function reference

- `opts` **[Object][7]**
- `opts` **[Object][9]**
### copy
[index.js:84-91][12]
Creates a copy of the funcRef
Returns **[FunctionRef][13]**
## ModuleRef
[index.js:92-120][10]
[index.js:97-125][14]

@@ -50,8 +60,8 @@ A module reference

- `exports` **[Object][7]** a map of exported function to params for the funcion if any
- `id` **[ID][11]** the id of the actor
- `exports` **[Object][9]** a map of exported function to params for the funcion if any
- `id` **[ID][15]** the id of the actor
### getFuncRef
[index.js:107-115][12]
[index.js:112-120][16]

@@ -62,9 +72,9 @@ return a function refernce given the name of the function

- `name` **[string][13]**
- `name` **[string][17]**
Returns **[FunctionRef][14]**
Returns **[FunctionRef][13]**
## Message
[index.js:125-157][15]
[index.js:130-162][18]

@@ -77,4 +87,16 @@ **Extends EventEmitter**

- `opts` **[Object][7]**
- `opts` **[Object][9]**
## getType
[index.js:169-188][19]
returns the type that the object is
**Parameters**
- `obj` **any**
Returns **[String][17]**
[1]: #id

@@ -84,26 +106,34 @@

[3]: #moduleref
[3]: #copy
[4]: #getfuncref
[4]: #moduleref
[5]: #message
[5]: #getfuncref
[6]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L11-L18 "Source code on GitHub"
[6]: #message
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[7]: #gettype
[8]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L45-L60 "Source code on GitHub"
[8]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L5-L10 "Source code on GitHub"
[9]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L65-L87 "Source code on GitHub"
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[10]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L92-L120 "Source code on GitHub"
[10]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L37-L52 "Source code on GitHub"
[11]: #id
[11]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L57-L92 "Source code on GitHub"
[12]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L107-L115 "Source code on GitHub"
[12]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L84-L91 "Source code on GitHub"
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[13]: #functionref
[14]: #functionref
[14]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L97-L125 "Source code on GitHub"
[15]: https://github.com/primea/js-primea-objects/blob/3232a5e82edf2a3efc1f35a9be2159d416bca00d/index.js#L125-L157 "Source code on GitHub"
[15]: #id
[16]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L112-L120 "Source code on GitHub"
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[18]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L130-L162 "Source code on GitHub"
[19]: https://github.com/primea/js-primea-objects/blob/19ce496560f9ea1fb3b35eefab4afbe9b8d581eb/index.js#L169-L188 "Source code on GitHub"
const cbor = require('borc')
const EventEmitter = require('events')
const Buffer = require('safe-buffer').Buffer

@@ -11,11 +12,2 @@ const TAGS = {

const DEFAULTS = {
elem: [],
data: Buffer.from([]),
id: new cbor.Tagged(TAGS.id, 0),
mod: new cbor.Tagged(TAGS.mod, [{}, new cbor.Tagged(TAGS.id, 0)]),
link: new cbor.Tagged(TAGS.link, null),
func: new cbor.Tagged(TAGS.func, 0)
}
/**

@@ -89,2 +81,6 @@ * a cbor decoder for the objects

/**
* Creates a copy of the funcRef
* @returns {FunctionRef}
*/
copy () {

@@ -170,2 +166,28 @@ return new FunctionRef({

/**
* returns the type that the object is
* @param {*} obj
* @return {String}
*/
function getType (obj) {
if (obj) {
if (Buffer.isBuffer(obj)) {
return 'data'
} else if (Array.isArray(obj)) {
return 'elem'
} else if (obj['/']) {
return 'link'
} else if (obj.constructor === Message) {
return 'message'
} else if (obj.constructor === ID) {
return 'id'
} else if (obj.constructor === FunctionRef) {
return 'func'
} else if (obj.constructor === ModuleRef) {
return 'mod'
}
}
return 'invalid'
}
module.exports = {

@@ -176,4 +198,4 @@ Message,

ModuleRef,
DEFAULTS,
decoder
decoder,
getType
}
{
"name": "primea-objects",
"version": "0.0.2",
"version": "0.0.3",
"description": "Object helper classes for Primea's system Objects",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,1 +1,2 @@

const Buffer = require('safe-buffer').Buffer
const tape = require('tape')

@@ -6,2 +7,5 @@ const cbor = require('borc')

tape('system objects', t => {
t.equals(objects.getType(), 'invalid')
t.equals(objects.getType(true), 'invalid')
const msg = new objects.Message({

@@ -11,2 +15,3 @@ ticks: 100

t.equals(objects.getType(msg), 'message')
t.equals(msg.ticks, 100)

@@ -20,2 +25,3 @@ msg.ticks = 10

t.equals(rid.toString(), '01')
t.equals(objects.getType(id), 'id')

@@ -25,2 +31,3 @@ const modRef = new objects.ModuleRef({'name': ['i32']}, id)

const rmodRef = objects.decoder.decodeFirst(enmod)
t.equals(objects.getType(modRef), 'mod')
t.deepEquals(modRef, rmodRef)

@@ -36,2 +43,3 @@

t.deepEquals(funcRef, rFuncRef)
t.equals(objects.getType(rFuncRef), 'func')

@@ -42,4 +50,8 @@ const link = new cbor.Tagged(42, 'data')

t.deepEquals(rLink, {'/': 'data'})
t.equals(objects.getType(rLink), 'link')
t.equals(objects.getType([]), 'elem')
t.equals(objects.getType(Buffer.from([])), 'data')
t.end()
})

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

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

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