{"id":19621278,"url":"https://github.com/commenthol/serialize-to-module","last_synced_at":"2025-07-02T17:10:04.127Z","repository":{"id":57372312,"uuid":"188458840","full_name":"commenthol/serialize-to-module","owner":"commenthol","description":"serialize objects to node module","archived":false,"fork":false,"pushed_at":"2021-04-04T10:30:06.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T03:39:21.958Z","etag":null,"topics":["javascript","serialize","serialize-objects"],"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/commenthol.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":"2019-05-24T16:59:04.000Z","updated_at":"2021-04-04T10:30:08.000Z","dependencies_parsed_at":"2022-09-01T17:32:05.749Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/serialize-to-module","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/commenthol/serialize-to-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fserialize-to-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fserialize-to-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fserialize-to-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fserialize-to-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/serialize-to-module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fserialize-to-module/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263182276,"owners_count":23426635,"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":["javascript","serialize","serialize-objects"],"created_at":"2024-11-11T11:22:13.644Z","updated_at":"2025-07-02T17:10:04.056Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","readme":"# serialize-to-module\n\n\u003e serialize objects to node module\n\n[![NPM version](https://badge.fury.io/js/serialize-to-module.svg)](https://www.npmjs.com/package/serialize-to-module/)\n[![Build Status](https://secure.travis-ci.org/commenthol/serialize-to-module.svg?branch=master)](https://travis-ci.org/commenthol/serialize-to-module)\n\nSerialize objects into a `require`-able module while checking circular structures and respecting references.\n\nThe following Objects are supported\n\n- String\n- Number\n- Boolean\n- Object\n- Array\n- RegExp\n- Error\n- Date\n- Buffer\n- Int8Array, Uint8Array, Uint8ClampedArray\n- Int16Array, Uint16Array\n- Int32Array, Uint32Array, Float32Array\n- Float64Array\n\n## Table of Contents\n\n\u003c!-- !toc (minlevel=2 omit=\"Table of Contents\") --\u003e\n\n* [Methods](#methods)\n  * [serializeToModule](#serializetomodule)\n* [Contribution and License Agreement](#contribution-and-license-agreement)\n* [License](#license)\n\n\u003c!-- toc! --\u003e\n\n## Methods\n\n### serializeToModule\n\n`serializeToModule(source, opts, opts.ignoreCircular, opts.reference, opts.comment, opts.beautify) `\n\nserialize to a module which can be `require`ed.\n\n#### Example - serializing while respecting references\n\n```js\nconst serialTM = require('serialize-to-module')\nconst obj = { object: { regexp: /^test?$/ } }\nobj.reference = obj.object\nconsole.log(serialTM(obj, { reference: true }))\n//\u003e var m = {\n//\u003e   object: {\n//\u003e     regexp: /^test?$/\n//\u003e   }\n//\u003e };\n//\u003e m.reference = m.object;\n//\u003e module.exports = m;\n```\n\n**Parameters**\n\n**source**: `Object | Array | function | Any`, source to serialize\n\n**opts**: `Object`, options\n\n**opts.ignoreCircular**: `Boolean`, ignore circular objects\n\n**opts.reference**: `Boolean`, reference instead of a copy (requires post-processing of opts.references)\n\n**opts.comment**: `Boolean`, add a comments - useful for linting tools e.g. using 'eslint-disable'\n\n**opts.beautify**: `Boolean | Object`, beautify output - default is `false`. If Object then use je-beautify options.\n\n**opts.unsafe**: `Boolean`, do not escape chars `\u003c\u003e/`\n\n**opts.esm**: `Boolean`, use `export default` instead of common js `module.exports`\n\n**Returns**: `String`, serialized representation of `source` as module\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your\ncode to be distributed under the MIT license. You are also implicitly\nverifying that all code is your original work or correctly attributed\nwith the source of its origin and licence.\n\n## License\n\nCopyright (c) 2016- commenthol (MIT License)\n\nSee [LICENSE][] for more info.\n\n[LICENSE]: ./LICENSE\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fserialize-to-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fserialize-to-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fserialize-to-module/lists"}