{"id":31785433,"url":"https://github.com/mdvorak/js-java-properties","last_synced_at":"2026-03-11T06:32:09.334Z","repository":{"id":153148780,"uuid":"615366902","full_name":"mdvorak/js-java-properties","owner":"mdvorak","description":"Java properties file parser and formatter for Javascript.","archived":false,"fork":false,"pushed_at":"2026-02-02T02:06:42.000Z","size":692,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-02T11:50:45.627Z","etag":null,"topics":["formatter","java","parser","properties","stringify","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mdvorak.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-17T14:31:39.000Z","updated_at":"2026-02-02T02:06:46.000Z","dependencies_parsed_at":"2026-02-14T07:11:25.339Z","dependency_job_id":null,"html_url":"https://github.com/mdvorak/js-java-properties","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mdvorak/js-java-properties","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdvorak%2Fjs-java-properties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdvorak%2Fjs-java-properties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdvorak%2Fjs-java-properties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdvorak%2Fjs-java-properties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdvorak","download_url":"https://codeload.github.com/mdvorak/js-java-properties/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdvorak%2Fjs-java-properties/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30373463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["formatter","java","parser","properties","stringify","typescript"],"created_at":"2025-10-10T11:55:04.929Z","updated_at":"2026-03-11T06:32:09.302Z","avatar_url":"https://github.com/mdvorak.png","language":"TypeScript","readme":"# js-java-properties\n\nThis is a small library that provides utilities to parse and\nmanipulate [Java properties](https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html) files.\n\nIntended mostly for the tools that need to modify an existing property file without reformatting the contents. This is\nachieved by using a string array as a backing storage. If you want only to read the properties, you should convert it to\nan object or a `Map` using `toObject(...)` or `toMap(...)` function, respectively.\n\n## Usage\n\nYou can install this library using NPM:\n\n```shell\nnpm install js-java-properties\n```\n\n### Types\n\n- `Properties` represent lines in the properties file. A single property can span multiple lines.\n  It is a part of the API, and it may be extended in future versions.\n- `KeyValuePair` parsed key and value. Used by `listProperties`.\n\n### Parsing\n\nParses correctly file contents as a string into lines.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.parse('key1=value1\\nkey2 = value2\\nkey3: value3')\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key2 = value2', 'key3: value3' ] }\n```\n\nTo read a file from a disk, use standard node `fs` module:\n\n```ts\nimport fs from 'node:fs'\nimport * as properties from 'js-java-properties'\n\nconst props = properties.parse(fs.readFileSync('file.properties', 'utf-8'))\n```\n\n### Stringify\n\nFormats property lines into string.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\n\nconst output = properties.stringify(props)\nconsole.log(output)\n// 'key1=value1\\nkey2 = value2\\nkey3: value3\\n'\n```\n\n### Listing key-value pairs\n\nIterate over every key-value pair. Note that if file contains duplicate keys,\nthey are returned here as well.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('# comment')\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\nprops.lines.push('key3: duplicate')\n\nfor (const {key, value} of properties.listProperties(props)) {\n  console.log(`${key}=${value}`)\n  // key1=value1\n  // key2=value2\n  // key3=value3\n  // key3=duplicate\n}\n```\n\n### Getting a value by key\n\nNote that this method has `O(n)` complexity for every operation.\nUse `toObject` or `toMap` methods to convert it into a readable object.\n\nIn case there are duplicate keys, the last one is returned.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\n\nconsole.log(properties.getProperty(props, 'key2'))\n// 'value2'\n\nprops.lines.push('key2 = duplicate')\nconsole.log(properties.getProperty(props, 'key2'))\n// 'duplicate'\n```\n\n### Converting to object or map\n\nIn case there are duplicate keys, the last one is returned.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\n\nconsole.log(properties.toObject(props))\n// { key1: 'value1', key2: 'value2', key3: 'value3' }\n\nconsole.log(properties.toMap(props))\n// Map(3) { 'key1' =\u003e 'value1', 'key2' =\u003e 'value2', 'key3' =\u003e 'value3' }\n```\n\n### Setting a value\n\nThis method adds or replaces the given key-value pair. If the value is undefined, the key is removed.\nNote that an empty string is still considered a value.\n\nIf there are multiple occurrences of the same key in the list, only the first one is kept and\nall other occurrences are removed.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\n\nproperties.setProperty(props, 'key2', 'new-value')\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key2 = new-value', 'key3: value3' ] }\n\nproperties.setProperty(props, 'new-key', 'new-value')\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key2 = new-value', 'key3: value3', 'new-key: new-value' ] }\n\nproperties.setProperty(props, 'new-key', 'new-value', {separator: ' = '})\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key2 = new-value', 'key3: value3', 'new-key = new-value' ] }\n\nproperties.setProperty(props, 'key3', undefined)\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key2 = new-value', 'new-key = new-value' ] }\n```\n\n### Removing a value\n\nRemoves the given key and its associated value. If there are duplicate keys with the same name,\nall values associated with the given key are removed.\n\n```ts\nimport * as properties from 'js-java-properties'\n\nconst props = properties.empty()\nprops.lines.push('key1=value1', 'key2 = value2', 'key3: value3')\n\nproperties.removeProperty(props, 'key2')\nconsole.log(props)\n// { lines: [ 'key1=value1', 'key3: value3' ] }\n```\n\n## Development\n\n- Commits must follow [Conventional Commits](https://www.conventionalcommits.org) standard\n- Code must conform to eslint and prettier rules\n- 100% test coverage is required\n\n### Publishing\n\nThis package uses [Release Please](https://github.com/googleapis/release-please) to generate releases.\nThe package is automatically published to a [npm registry](https://www.npmjs.com/package/js-java-properties)\nwhen release is created.\n\n## Contributing\n\nIf you would like to contribute to this library, feel free to submit a pull request on GitHub.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdvorak%2Fjs-java-properties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdvorak%2Fjs-java-properties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdvorak%2Fjs-java-properties/lists"}