{"id":18285932,"url":"https://github.com/exodusmovement/varstruct-cstring","last_synced_at":"2025-04-05T08:30:37.114Z","repository":{"id":44125090,"uuid":"71175290","full_name":"ExodusMovement/varstruct-cstring","owner":"ExodusMovement","description":"Easily encode / decode strings as null-terminated C strings.","archived":false,"fork":false,"pushed_at":"2023-05-12T23:08:28.000Z","size":85,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-04-24T20:13:28.566Z","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":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExodusMovement.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-17T19:50:06.000Z","updated_at":"2024-01-12T18:09:06.000Z","dependencies_parsed_at":"2023-01-22T07:45:40.772Z","dependency_job_id":null,"html_url":"https://github.com/ExodusMovement/varstruct-cstring","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fvarstruct-cstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fvarstruct-cstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fvarstruct-cstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fvarstruct-cstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExodusMovement","download_url":"https://codeload.github.com/ExodusMovement/varstruct-cstring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223174746,"owners_count":17100272,"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-11-05T13:18:13.128Z","updated_at":"2024-11-05T13:18:13.836Z","avatar_url":"https://github.com/ExodusMovement.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"varstruct-cstring\n=================\n\n[![npm](https://img.shields.io/npm/v/varstruct-cstring.svg?style=flat-square)](https://www.npmjs.com/package/varstruct-cstring)\n[![Build Status](https://img.shields.io/github/workflow/status/ExodusMovement/varstruct-cstring/CI/master?style=flat-square)](https://github.com/ExodusMovement/varstruct-cstring/actions?query=branch%3Amaster)\n[![JavaScript standard style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com)\n\nEasily encode / decode strings as [C strings](https://en.wikibooks.org/wiki/C_Programming/Strings), that is, null-terminated `\\0`.\nThis is useful to retain compatibility with data structures written in other languages.\n\n\nInstall\n-------\n\n    npm i --save varstruct #must install varstruct first\n    npm i --save varstruct-cstring\n\n\nExample\n-------\n\n```js\nconst vstruct = require('varstruct')\nconst cstring = require('varstruct-cstring')\n\nconst strings = vstruct([\n  { name: 'first', type: cstring(16) },\n  { name: 'last', type: cstring(16) }\n])\n\nconst data = {\n  first: 'Satoshi',\n  last: 'Nakamoto'\n}\n\nconst buffer = strings.encode(data)\nconsole.log(buffer.toString('hex')) // =\u003e '5361746f7368690000000000000000004e616b616d6f746f0000000000000000'\n\nconst decodedData = strings.decode(buffer)\nconsole.dir(decodedData) // =\u003e { first: 'Satoshi', last: 'Nakamoto' }\n```\n\n\nLicense\n-------\n\nMIT Copyright Exodus Movement, Inc. 2016\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fvarstruct-cstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexodusmovement%2Fvarstruct-cstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fvarstruct-cstring/lists"}