{"id":13453545,"url":"https://github.com/EOSIO/eosjs-fcbuffer","last_synced_at":"2025-03-24T01:31:36.319Z","repository":{"id":24553729,"uuid":"99264478","full_name":"EOSIO/eosjs-fcbuffer","owner":"EOSIO","description":"Serialization library geared towards immutable data storage such as blockchains.","archived":false,"fork":true,"pushed_at":"2023-04-18T19:40:20.000Z","size":323,"stargazers_count":27,"open_issues_count":12,"forks_count":19,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-15T17:22:50.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jcalfee/fcbuffer","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EOSIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-03T18:44:22.000Z","updated_at":"2023-04-01T19:07:30.000Z","dependencies_parsed_at":"2023-01-16T22:02:37.811Z","dependency_job_id":null,"html_url":"https://github.com/EOSIO/eosjs-fcbuffer","commit_stats":null,"previous_names":["eosio/fcbuffer"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-fcbuffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-fcbuffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-fcbuffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-fcbuffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EOSIO","download_url":"https://codeload.github.com/EOSIO/eosjs-fcbuffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194248,"owners_count":20575728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:42.799Z","updated_at":"2025-03-24T01:31:35.375Z","avatar_url":"https://github.com/EOSIO.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/EOSIO/eosjs-fcbuffer.svg?branch=master)](https://travis-ci.org/EOSIO/eosjs-fcbuffer)\n[![Coverage Status](https://coveralls.io/repos/github/EOSIO/eosjs-fcbuffer/badge.svg?branch=master)](https://coveralls.io/github/EOSIO/eosjs-fcbuffer?branch=master)\n[![NPM](https://img.shields.io/npm/v/fcbuffer.svg)](https://www.npmjs.org/package/fcbuffer)\n\n# FC Buffer\n\nSerialization library geared towards immutable data storage such as blockchains.\n\nFor EOS compatible implementation use this library from [eosjs](https://github.com/eosio/eosjs) instead.\n\nFC Buffer is a recent refactor from serialization code used in Bitshares and\nSteem.  Some of the serialization code was reduced and the definitions language\nadded.  The definition format may change.\n\n# Features\n\n- Validation and error reporting\n- Concise and intuitive binary format\n- Compatible with the FC library used in Graphene blockchains\n- Extendable JSON structure definitions\n- Binary and JSON string serialization\n- Unit testing and code coverage\n\n# Non Features\n\n- Consider Cap'n Proto or Protocol Buffers if your data structures need to\n  be extended at the serialization layer.\n- No streams, smaller blockchain sized objects are used\n\n# Example\n\n```javascript\nFcbuffer = require('fcbuffer') // or: Fcbuffer = require('./src')\n\nassert = require('assert')\n\ndefinitions = {\n    message_type: 'fixed_string16', // CustomType: built-in type\n    account_name: 'fixed_string32', // CustomType: built-in type\n    message: { // struct\n        fields: {\n          from: 'account_name',\n          to: 'account_name',\n          cc: 'account_name[]',\n          type: 'message_type',\n          data: 'bytes' // built-in type\n        }\n    }\n}\n\n// Warning: Do not use {defaults: true} in production\nfcbuffer = Fcbuffer(definitions, {defaults: true})\n\n// Check for errors anywhere in the definitions structure\nassert(fcbuffer.errors.length === 0, fcbuffer.errors)\n\n// If there are no errors, you'll get your structs\nvar {message} = fcbuffer.structs\n\n// Create JSON serializable object\n// returns { from: '', to: '', cc: [ '' ], type: '', data: '' }\nmessage.toObject()\n\n// Convert JSON into a more compact fcbuffer serializable object\nmsg = { from: 'jc', to: 'dan', cc: [ 'abc' ], type: '', data: '0f0f0f' }\n\n// Serialize fcbuffer object into a single binary buffer\nbuf = Fcbuffer.toBuffer(message, msg)\n// returns \u003cBuffer 02 6a 63 07 63 68 61 72 6c 65 73 01 03 61 62 63 00 03 0f 0f 0f\u003e\n\n// Convert binary back into a new (cloned) object\nobj = Fcbuffer.fromBuffer(message, buf)\n\n// Check that the new object matches the original\nassert.deepEqual(msg, obj)\n\n// A definition may extend and define other definitions.  This works in the initial\n// definition or later via the extend function.\nfcbuffer2 = fcbuffer.extend({\n    permission_name: 'fixed_string16',\n    permission_level: {\n        fields: {\n          actor: 'account_name',\n          permission: 'permission_name'\n        }\n    }\n})\n\nassert(fcbuffer2.errors.length === 0, fcbuffer2.errors)\n\nvar {permission_level} = fcbuffer2.structs\npermission_level.toObject()\n// toObject returns: { actor: '', permission: '' }\n\n```\n\n# References\n\n- Built-in Types: [types.js](./src/types.js)\n- EOS Definitions: [schema](https://github.com/EOSIO/eosjs-json/blob/master/schema)\n\n# Environment\n\nNode 6+ and browser (browserify, webpack, etc)\n","funding_links":[],"categories":["Language Support"],"sub_categories":["JavaScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs-fcbuffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEOSIO%2Feosjs-fcbuffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs-fcbuffer/lists"}