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

ref

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ref - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

6

History.md
0.0.4 / 2012-05-08
==================
- README improvements; some API documentation
- removed some leftover debugging statements
0.0.3 / 2012-05-08

@@ -3,0 +9,0 @@ ==================

2

lib/ref.js

@@ -135,5 +135,3 @@

var len = buffer.write(string, offset, size, encoding)
console.error('write %d bytes!', len)
buffer.writeUInt8(0, offset + len) // NUL terminate
console.error(buffer)
}

@@ -140,0 +138,0 @@

@@ -19,3 +19,3 @@ { "name": "ref"

]
, "version": "0.0.3"
, "version": "0.0.4"
, "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)"

@@ -22,0 +22,0 @@ , "repository": { "type": "git", "url": "git://github.com/TooTallNate/ref.git" }

@@ -13,3 +13,3 @@ ref

#### Features:
### Features:

@@ -24,2 +24,3 @@ * Get the memory address of any `Buffer` instance

Installation

@@ -67,2 +68,97 @@ ------------

Additions to `Buffer.prototype`
-------------------------------
`ref` extends Node's core `Buffer` instances with some useful additions:
#### `Buffer#address()` → Number
Returns the memory address of the Buffer instance.
#### `Buffer#isNull()` → Boolean
Returns `true` if the Buffer's memory address is NULL, `false` otherwise.
#### `Buffer#ref()` → Buffer
Returns a new Buffer instance that is referencing this Buffer. That is, the new
Buffer is "pointer" sized, and points to the memory address of this Buffer.
The returned Buffer's `type` property gets set properly as well, with an
`indirection` level increased by 1.
#### `Buffer#deref()` → ???
Returns the dereferenced value from the Buffer instance. This depends on the
`type` property being set to a proper "type" instance (see below).
The returned value can be another Buffer, or pretty much be anything else,
depending on the `get()` function of the "type" instance and current
`indirection` level of the Buffer.
#### `Buffer#readObject(Number offset)` → Object
Returns the JS `Object` that has previously been written to the Buffer at the
given offset using `writeObject()`.
#### `Buffer#writeObject(Object obj, Number offset)` → undefined
Writes the given JS `Object` to the Buffer at the given offset. Make sure that at
least `ref.sizeof.Object` bytes are available in the Buffer after the specified
offset. The object can later be retrieved using `readObject()`.
#### `Buffer#readPointer(Number offset, Number size)` → Buffer
Returns a new Buffer instance pointing to the address specified in this Buffer at
the given offset. The `size` is the length of the returned Buffer, which defaults
to 0.
#### `Buffer#writePointer(Buffer pointer, Number offset)` → undefined
Writes the given Buffer's memory address to this Buffer at the given offset. Make
sure that at least `ref.sizeof.pointer` bytes are available in the Buffer after
the specified offset. The Buffer can later be retrieved again using
`readPointer()`.
#### `Buffer#readCString(Number offset)` → String
Returns a JS String from read from the Buffer at the given offset. The C String is
read up til the first NULL byte, which indicates the end of the C String.
This function can read beyond the length of a Buffer, and reads up until the first
NULL byte regardless.
#### `Buffer#writeCString(String string, Number offset, String encoding)` → undefined
Writes `string` as a C String (i.e. NULL terminated) to this Buffer at the given
offset. `encoding` is optional and defaults to `utf8`.
#### `Buffer#readInt64[native-endianness](Number offset)` → Number|String
Returns a Number or String representation of the 64-bit int read from this Buffer
at the given offset. If the returned value will fit inside a Number without losing
precision, then a Number is returned, otherwise a String is returned.
#### `Buffer#writeInt64[native-endianness](Number|String value, Number offset)` → undefined
Writes an value as a `int64_t` to this Buffer at the given offset. `value` may be
either a Number or a String representing the 64-bit int value. Ensure that at
least `ref.sizeof.int64` (always 8) bytes are available in the Buffer after the
given offset.
#### `Buffer#readUInt64[native-endianness](Number offset)` → Number|String
Returns a Number or String representation of the 64-bit unsigned int read from
this Buffer at the given offset. If the returned value will fit inside a
Number without losing precision, then a Number is returned, otherwise a String
is returned.
#### `Buffer#writeUInt64[native-endianness](Number|String value, Number offset)` → undefined
Writes an value as a `int64_t` to this Buffer at the given offset. `value` may be
either a Number or a String representing the 64-bit unsigned int value. Ensure
that at least `ref.sizeof.uint64` (always 8) bytes are available in the Buffer
after the given offset.
The "type" interface

@@ -69,0 +165,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