{"id":16718879,"url":"https://github.com/kgryte/eval-serialize-buffer","last_synced_at":"2025-03-15T10:24:52.137Z","repository":{"id":36341123,"uuid":"40645847","full_name":"kgryte/eval-serialize-buffer","owner":"kgryte","description":"Serializes a Buffer object for dynamic code evaluation.","archived":false,"fork":false,"pushed_at":"2015-08-15T07:05:31.000Z","size":124,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T10:38:16.457Z","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/kgryte.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-08-13T07:48:31.000Z","updated_at":"2019-08-18T16:49:46.000Z","dependencies_parsed_at":"2022-09-04T17:51:34.639Z","dependency_job_id":null,"html_url":"https://github.com/kgryte/eval-serialize-buffer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgryte%2Feval-serialize-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgryte%2Feval-serialize-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgryte%2Feval-serialize-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgryte%2Feval-serialize-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kgryte","download_url":"https://codeload.github.com/kgryte/eval-serialize-buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243715430,"owners_count":20335934,"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-10-12T21:38:59.715Z","updated_at":"2025-03-15T10:24:52.110Z","avatar_url":"https://github.com/kgryte.png","language":"JavaScript","readme":"Buffer Serialization\n===\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]\n\n\u003e Serializes a [Buffer](https://nodejs.org/api/buffer.html) object for dynamic code evaluation.\n\n\n## Installation\n\n``` bash\n$ npm install eval-serialize-buffer\n```\n\n## Usage\n\n``` javascript\nvar serialize = require( 'eval-serialize-buffer' );\n```\n\n#### serialize( value )\n\nSerializes a [`Buffer`](https://nodejs.org/api/buffer.html) object for dynamic code evaluation.\n\n``` javascript\nvar deepEqual = require( 'deep-equal' );\n\nvar b1 = new Buffer( 'beep' );\n\nvar str = serialize( b1 );\n// returns 'new Buffer(\"YmVlcA==\",\"base64\")'\n\nvar b2 = eval( str );\n// returns Buffer( 'beep' )\n\nvar bool = deepEqual( b1, b2 );\n// returns true\n```\n\n\n#### serialize.raw( buffer )\n\nSerializes a [`Buffer`](https://nodejs.org/api/buffer.html) object without performing type checking.\n\n``` javascript\ntry {\n\t// throws during input argument validation...\n\tserialize( null );\n} catch ( err ) {\n\tconsole.error( err );\n}\n\n// To bypass validation...\nvar str = serialize.raw( new Buffer( 'boop' ) );\n// returns 'new Buffer(\"Ym9vcA==\",\"base64\")';\n```\n\n\n## Examples\n\n``` javascript\nvar serialize = require( 'eval-serialize-buffer' );\n\n/**\n* Returns a function to create a filled array.\n*/\nfunction create( b ) {\n\tvar f = '';\n\tf += 'return function fill( len ) {';\n\tf += 'var arr = new Array( len );';\n\tf += 'for ( var i = 0; i \u003c len; i++ ) {';\n\tf += 'arr[ i ] = ' + serialize( b ) + ';';\n\tf += '}';\n\tf += 'return arr;';\n\tf += '}';\n\treturn ( new Function( f ) )();\n}\n\nvar fill = create( new Buffer( 'beepboop' ) );\n\nconsole.log( fill( 10 ) );\n```\n\nTo run the example code from the top-level application directory,\n\n``` bash\n$ node ./examples/index.js\n```\n\n\n## Tests\n\n### Unit\n\nUnit tests use the [Mocha](http://mochajs.org/) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:\n\n``` bash\n$ make test\n```\n\nAll new feature development should have corresponding unit tests to validate correct functionality.\n\n\n### Test Coverage\n\nThis repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:\n\n``` bash\n$ make test-cov\n```\n\nIstanbul creates a `./reports/coverage` directory. To access an HTML version of the report,\n\n``` bash\n$ make view-cov\n```\n\n\n---\n## License\n\n[MIT license](http://opensource.org/licenses/MIT).\n\n\n## Copyright\n\nCopyright \u0026copy; 2015. Athan Reines.\n\n\n[npm-image]: http://img.shields.io/npm/v/eval-serialize-buffer.svg\n[npm-url]: https://npmjs.org/package/eval-serialize-buffer\n\n[travis-image]: http://img.shields.io/travis/kgryte/eval-serialize-buffer/master.svg\n[travis-url]: https://travis-ci.org/kgryte/eval-serialize-buffer\n\n[codecov-image]: https://img.shields.io/codecov/c/github/kgryte/eval-serialize-buffer/master.svg\n[codecov-url]: https://codecov.io/github/kgryte/eval-serialize-buffer?branch=master\n\n[dependencies-image]: http://img.shields.io/david/kgryte/eval-serialize-buffer.svg\n[dependencies-url]: https://david-dm.org/kgryte/eval-serialize-buffer\n\n[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/eval-serialize-buffer.svg\n[dev-dependencies-url]: https://david-dm.org/dev/kgryte/eval-serialize-buffer\n\n[github-issues-image]: http://img.shields.io/github/issues/kgryte/eval-serialize-buffer.svg\n[github-issues-url]: https://github.com/kgryte/eval-serialize-buffer/issues\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkgryte%2Feval-serialize-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkgryte%2Feval-serialize-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkgryte%2Feval-serialize-buffer/lists"}