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

marsha

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

marsha

Parser/serializer for Ruby's marshal format

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Marsha

Read/write simple output from Ruby's Marshal library.

How simple? I serialize everything with Marshal.dump and want to use it to interop with other langs for some reason

This is not for you. First of all, don't use Marshal for that. And second of all, no smoking.

F----- OFFFF

I want to exchange data with Ruby/Rails apps that store simple values in Marshal format

Now we're talking.

I've done basics like true, false and nil, Fixnums, Floats, strings that just contain ASCII/latin1 chars, arrays and hashes. Coverage of what can be serialized is far from exhaustive.

OK, That Suits My Needs

Usage:

var marsha = require('marsha');

Marshaled data contains all sorts of nonprintable characters; you can provide it as a buffer:

var buffer = fs.readFileSync('./data/marshaled');
marsha.load(buffer);

Or you can provide a string and an encoding, a buffer will be created internally.

marsha.load('BAhbCGkGaQdpCA==', 'base64'); // returns [ 1, 2, 3 ]

The JS representation of the marshaled data will be returned, or an exception will be thrown if it's not usable. Marshal can serialize a wide variety of Ruby objects including instances of builtin and user defined classes, which may not have a JS equivalent. :symbols are treated as strings in JS land.

Writing is similar to reading, returns a buffer if called with one argument:

marsha.dump([ 1, 2, 3 ]); // returns <Buffer 04 08 5b 08 69 06 69 07 69 08>

or a string if called with two:

marsha.dump([ 1, 2, 3 ], 'base64'); // returns 'BAhbCGkGaQdpCA=='

Tests

npm test

Most coverage is generated from test/examples.json, which contains various hex-encoded outputs from asking Marshal to encode things in irb, and their JS equivalents.

Keywords

FAQs

Package last updated on 21 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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