{"id":21018581,"url":"https://github.com/kenote/parse-string","last_synced_at":"2026-04-27T09:31:08.871Z","repository":{"id":57319584,"uuid":"306791561","full_name":"kenote/parse-string","owner":"kenote","description":"Parse the string into a Map.","archived":false,"fork":false,"pushed_at":"2025-01-22T09:53:44.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T02:35:10.838Z","etag":null,"topics":["filter","format","map","msgbody","parser","validator"],"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/kenote.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,"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":"2020-10-24T02:43:51.000Z","updated_at":"2025-01-22T09:53:47.000Z","dependencies_parsed_at":"2025-12-27T12:03:24.439Z","dependency_job_id":null,"html_url":"https://github.com/kenote/parse-string","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/kenote/parse-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenote%2Fparse-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenote%2Fparse-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenote%2Fparse-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenote%2Fparse-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenote","download_url":"https://codeload.github.com/kenote/parse-string/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenote%2Fparse-string/sbom","scorecard":{"id":555500,"data":{"date":"2025-08-11","repo":{"name":"github.com/kenote/parse-string","commit":"982be48bda7768eebc211d6bfd502e48cd50ef0d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T12:13:55.542Z","repository_id":57319584,"created_at":"2025-08-20T12:13:55.543Z","updated_at":"2025-08-20T12:13:55.543Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32331305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["filter","format","map","msgbody","parser","validator"],"created_at":"2024-11-19T10:26:38.348Z","updated_at":"2026-04-27T09:31:08.841Z","avatar_url":"https://github.com/kenote.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parse-string\n\nParse the string into a Map.\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Gratipay][licensed-image]][licensed-url]\n\n## Installation\n\n```bash\n$ npm install parse-string\n#\n$ yarn add parse-string\n```\n\n## Features\n\n- parse string into Map\n- format data\n- filter and verify data.\n- verify signature.\n\n## API\n\n### toValue (type: 'string' | 'number' | 'date' | 'map' = 'string'): (value: any) =\u003e any\n\nConvert specified type value.\n\n- `type` - target type\n- `value` - value of need convert\n\n### formatData (formats?: ParseData.format | ParseData.format[], customize?: Record\u003cstring, Function\u003e): (value: any) =\u003e any\n\nFormat Data.\n\n- `formats` - formatting options\n- `customize` - map of custom function\n- `value` - value of need format\n\n### parseData (options: ParseData.options, customize?: Record\u003cstring, Function\u003e): (data: string) =\u003e Record\u003cstring, any\u003e\n\nParse the string to the specified result.\n\n- `options` - parsing options\n- `customize` - map of custom function\n- `data` - data of need parse\n\n### parseBody (options: ParseData.parse[], customize?: Record\u003cstring, Function\u003e): (msgbody: Record\u003cstring, any\u003e) =\u003e Record\u003cstring, any\u003e\n\nParse the msbody to the specified result.\n\n- `options` - parsing options\n- `customize` - map of custom function\n- `msbody` - msbody of need parse\n\n### filterData (options: FilterData.options[], customize?: Record\u003cstring, Function\u003e): (data: Record\u003cstring, any\u003e) =\u003e Record\u003cstring, any\u003e\n\nFilter and verify data.\n\n- `options` - filter options\n- `customize` - map of custom function\n- `data` - data of need filter\n\n### validSign (options: string, sign: string = 'sign'): (data: Record\u003cstring, any\u003e) =\u003e boolean\n\nVerify signature.\n\n- `options` - style of signature\n- `sign` - feild of signature\n- `data` - data of submit\n\n## Usages\n\nExample: Parse string\n\n```js\nimport { parseData } from 'parse-string'\n\nconst customize = {\n  add: (a, b) =\u003e a + b\n}\n\nconst options = {\n  separator: /\\;/,\n  collection: [\n    {\n      key: 'date',\n      type: 'string',\n      format: [\n        {\n          type: 'string',\n          regexp: /^(\\d{4})(\\d{2})(\\d{2})$/,\n          substr: '$1-$2-$3'\n        },\n        {\n          type: 'date'\n        }\n      ]\n    },\n    {\n      key: 'amount',\n      type: 'number'\n    },\n    {\n      key: 'user',\n      type: 'map'\n    },\n    {\n      key: 'username',\n      result: {\n        defaultValue: '$__user'\n      },\n      format: {\n        type: 'map',\n        maps: 'username'\n      }\n    },\n    {\n      key: 'group',\n      result: {\n        defaultValue: '$__user'\n      },\n      format: {\n        type: 'map',\n        maps: 'group.name'\n      }\n    },\n    {\n      key: 'level',\n      result: {\n        defaultValue: '$__user'\n      },\n      format: {\n        type: 'map',\n        maps: 'group.level'\n      }\n    },\n    {\n      key: 'money1',\n      result: {\n        defaultValue: '$__amount',\n        formula: {\n          exec: (a, b) =\u003e a + b,\n          opts: [ '$__amount', '$__level' ]\n        }\n      }\n    },\n    {\n      key: 'money2',\n      result: {\n        defaultValue: '$__amount',\n        formula: {\n          exec: 'add',\n          opts: [ '$__amount', '$__level' ]\n        }\n      }\n    }\n  ],\n  omits: [ 'user' ]\n}\n\nconst data = '20201027;39554;{username:\\'thondery\\',group:{name:\\'管理员\\',level:9999}}'\n\nparseData(options, customize)(data)\n// { \n//   date: 2020-10-27T00:00:00.000Z,\n//   amount: 39554,\n//   username: 'thondery',\n//   group: '管理员',\n//   level: 9999,\n//   money1: 49553,\n//   money2: 49553 \n// }\n```\n\nExample: Filter and verify data\n\n```js\nimport { filterData, validSign } from 'parse-string'\n\nconst customize = {\n  isPassword: value =\u003e /^(?=.*[A-Za-z])[A-Za-z0-9$@$!%*#?\u0026]/.test(value)\n}\n\nconst options = [\n  {\n    key: 'username',\n    type: 'string',\n    rules: [\n      { required: true, message: '用户名不能为空' },\n      { min: 4, max: 12, message: '用户名长度不能小于4或大于12（字符）' },\n      { pattern: '^[a-zA-Z]{1}[a-zA-Z0-9\\_\\-]', message: '用户名格式错误' }\n    ]\n  },\n  {\n    key: 'password',\n    type: 'string',\n    rules: [\n      { required: true, message: '密码不能为空' },\n      { min: 6, max: 15, message: '密码长度不能小于6或大于15（字符）' },\n      { validator: 'isPassword', message: '密码格式错误' }\n    ]\n  },\n  {\n    key: 'items',\n    type: 'string[]',\n    defaultValue: []\n  },\n  {\n    key: 'sign',\n    type: 'string',\n    md5: '${password}${username}'\n  }\n]\n\nconst data = { username: 'thondery', password: 'a123456', items: '1001,1002,1003' }\n\ntry {\n  let result = filterData(options, customize)(data)\n  // {\n  //   username: 'thondery', \n  //   password: 'a123456', \n  //   items: ['1001', '1002', '1003'],\n  //   sign: '61a0375131b33b72b56e4e244d0b2f29'\n  // }\n} catch (error) {\n  console.error(error.message)\n}\n\nvalidSign('${password}${username}', 'sign')({ username: 'thondery', password: 'a123456', sign: '61a0375131b33b72b56e4e244d0b2f29' })\n// true or false\n```\n\n## License\n\nthis repo is released under the [MIT License](https://github.com/kenote/parse-string/blob/main/LICENSE).\n\n[npm-image]: https://img.shields.io/npm/v/parse-string.svg\n[npm-url]: https://www.npmjs.com/package/parse-string\n[downloads-image]: https://img.shields.io/npm/dm/parse-string.svg\n[downloads-url]: https://www.npmjs.com/package/parse-string\n[travis-image]: https://travis-ci.com/kenote/parse-string.svg?branch=main\n[travis-url]: https://travis-ci.com/kenote/parse-string\n[licensed-image]: https://img.shields.io/badge/license-MIT-blue.svg\n[licensed-url]: https://github.com/kenote/parse-string/blob/main/LICENSE","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenote%2Fparse-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenote%2Fparse-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenote%2Fparse-string/lists"}