{"id":13670524,"url":"https://github.com/appfigures/string-replace-to-array","last_synced_at":"2026-03-09T10:31:45.074Z","repository":{"id":47677167,"uuid":"57325670","full_name":"appfigures/string-replace-to-array","owner":"appfigures","description":"Like Javascript's string.replace, but accepts and returns an array","archived":false,"fork":false,"pushed_at":"2024-06-17T02:54:39.000Z","size":79,"stargazers_count":24,"open_issues_count":5,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-01T04:07:09.150Z","etag":null,"topics":["jsx","react","react-components","string-manipulation"],"latest_commit_sha":null,"homepage":"","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/appfigures.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}},"created_at":"2016-04-28T18:42:47.000Z","updated_at":"2024-10-11T10:36:48.000Z","dependencies_parsed_at":"2024-05-22T22:41:59.938Z","dependency_job_id":"32a600a6-3681-4d12-aecd-83bc3b8e2c03","html_url":"https://github.com/appfigures/string-replace-to-array","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.3846153846153846,"last_synced_commit":"e985900ac65affaff7eb4f285073d1ef11e902ff"},"previous_names":["oztune/string-replace-to-array"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/appfigures/string-replace-to-array","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Fstring-replace-to-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Fstring-replace-to-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Fstring-replace-to-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Fstring-replace-to-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfigures","download_url":"https://codeload.github.com/appfigures/string-replace-to-array/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Fstring-replace-to-array/sbom","scorecard":{"id":203507,"data":{"date":"2025-08-11","repo":{"name":"github.com/appfigures/string-replace-to-array","commit":"64bd8cd4e04ff68bfc39d2e6d2bb67676e6a291e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"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":"Code-Review","score":0,"reason":"Found 2/24 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":"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":"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":"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":"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":"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":"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 'master'"],"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T23:14:11.597Z","repository_id":47677167,"created_at":"2025-08-16T23:14:11.597Z","updated_at":"2025-08-16T23:14:11.597Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30291807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"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":["jsx","react","react-components","string-manipulation"],"created_at":"2024-08-02T09:00:44.246Z","updated_at":"2026-03-09T10:31:45.050Z","avatar_url":"https://github.com/appfigures.png","language":"JavaScript","readme":"# String replace to array\n\n[![string-replace-to-array MIT license on NPM](https://img.shields.io/npm/l/string-replace-to-array.svg?style=flat-square)](https://www.npmjs.com/package/string-replace-to-array)\n[![string-replace-to-array on NPM](https://img.shields.io/npm/v/string-replace-to-array.svg)](https://www.npmjs.com/package/string-replace-to-array)\n[![Build Status](https://img.shields.io/circleci/project/appfigures/string-replace-to-array.svg)](https://circleci.com/gh/appfigures/string-replace-to-array)\n[![string-replace-to-array total downloads on NPM](https://img.shields.io/npm/dt/string-replace-to-array.svg?style=flat-square)](https://www.npmjs.com/package/string-replace-to-array)\n[![string-replace-to-array monthly downloads on NPM](https://img.shields.io/npm/dm/string-replace-to-array.svg?style=flat-square)](https://www.npmjs.com/package/string-replace-to-array)\n\nWorks just like `String.prototype.replace` but outputs an array instead of a string. It's [tiny](https://bundlephobia.com/package/string-replace-to-array) (\u003c1KB) and has no dependencies.\n\n## Why?\n\nWe built this for use with React, but it's very generic and doesn't depend on any environment. Consider the following scenario.\n\nGiven this string:\n\n```\nvar content = 'Hello\\nworld'\n```\n\nand this React markup:\n\n```\n\u003cspan\u003e{ content }\u003c/span\u003e\n```\n\nWe'll get this output:\n```\nHello world\n```\n_The newline character is ignored when the browser renders the resulting html._\n\nThe solution is to replace `\\n` with `\u003cbr\u003e`:\n\n```\n\u003cspan\u003e{ replace(content, '\\n', \u003cbr\u003e) }\u003c/span\u003e\n```\n\nand the output will be:\n\n```\n\u003cspan\u003eHello\u003c/br\u003eworld\u003c/span\u003e\n```\nWhen rendered:\n```\nHello\nworld\n```\n\nNow the newline will be rendered properly. Yay!\n\n## Example usage\n\n### Simple example\n\n```\nvar replace = require('string-replace-to-array')\nreplace('Hello Amy', 'Amy', { name: 'Amy' })\n// output: ['Hello ', { name: 'Amy' }]\n```\n\n### Full example\n\n```\nreplace(\n  'Hello Hermione Granger...',\n  /(Hermione) (Granger)/g,\n  function (fullName, firstName, lastName, offset, string) {\n    return \u003cPerson firstName={ firstName } lastName={ lastName } /\u003e\n  }\n)\n\n// output: ['Hello ', \u003cPerson firstName=\"Hermione\" lastName=\"Granger\" /\u003e, ...]\n```\n\nFor a real-life example check out [react-easy-emoji](https://github.com/appfigures/react-easy-emoji), where this this is used to replace emoji unicode characters with `\u003cimg\u003e` tags.\n\n## Installation\n\n```\nnpm install --save string-replace-to-array\n```\n\n## API\n\n```\n(string, regexp|substr, newValue|function) =\u003e array\n```\n\nThe API mimics [String.prototype.replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace). The only differences are:\n\n- The replacer (third parameter) doesn't have to be a string\n- Returns an array instead of a string\n\n## Inspiration\n\nMainly inspired by this conversation: https://github.com/facebook/react/issues/3386\n\n### Why not use [react-replace-string](https://github.com/iansinnott/react-string-replace)?\n\nBecause we needed the full API of `String.replace`, especially the regex match parameters which get passed to the replace function.\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfigures%2Fstring-replace-to-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfigures%2Fstring-replace-to-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfigures%2Fstring-replace-to-array/lists"}