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

simplefunc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplefunc

Simple object with functions encode/decode, serialization/deserialization

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

SimpleFunc

Simple object with functions encode/decode, serialization/deserialization.

Installation

Via npm on Node:

npm install simplefunc

Usage

Sometimes, you need to define an object with attributes and functions, and send it to other machine or process. Functions are not serialized, so, an special processing is needed. SimpleFunc is a helper to encode objects with instance funcions so they can be serialized/deserializas from/to JSON. You can encode, decode without using JSON, too.

Reference in your program:

var simplefunc = require('simplefunc');

Encoding a value

var encoded = simplefunc.encode(value);

Most value are encoded as themselves. The current implementation returns an encoded result if the original value is an object and it has functions. If value is an object with functions, an object is returned, with two properties:

  • _obj: with the properties of the original value, that are NOT functions.
  • _fns: with the properties of the original value that ARE functions, encoding in an array with its parameters and code

Only the first level of properties is encoded: no attempt to make a deep encode (maybe in next versions).

If the value to encode is a function, an object is returned with an attribute _fn with an array containing the original function arguments and code serialized to string.

Encoding and decoding a value

var encoded = simplefunc.encode(value);
var newvalue = simplefunc.decode(encoded);

You can convert a value to/from a JSON string:

var json = simplefunc.toJson(value);
var newvalue = simplefunc.fromJson(encoded);

Development

git clone git://github.com/ajlopez/SimpleFunc.git
cd SimpleFunc
npm install
npm test

Samples

TBD

To do

  • Samples
  • Deep processing

Versions

  • 0.0.1 Published.
  • 0.0.2 Published. Fixed null processing.

Contribution

Feel free to file issues and submit pull requests � contributions are welcome.

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.

Keywords

FAQs

Package last updated on 16 Feb 2013

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