{"id":19238575,"url":"https://github.com/tmpfs/string-repeater","last_synced_at":"2025-02-23T13:52:53.910Z","repository":{"id":57372505,"uuid":"51500277","full_name":"tmpfs/string-repeater","owner":"tmpfs","description":"Repeat a string","archived":false,"fork":false,"pushed_at":"2016-02-11T09:54:49.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-05T02:12:19.495Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmpfs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-11T07:31:20.000Z","updated_at":"2019-04-27T04:00:09.000Z","dependencies_parsed_at":"2022-09-10T01:30:47.800Z","dependency_job_id":null,"html_url":"https://github.com/tmpfs/string-repeater","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fstring-repeater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fstring-repeater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fstring-repeater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fstring-repeater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmpfs","download_url":"https://codeload.github.com/tmpfs/string-repeater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240324059,"owners_count":19783453,"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-11-09T16:33:34.702Z","updated_at":"2025-02-23T13:52:53.890Z","avatar_url":"https://github.com/tmpfs.png","language":"JavaScript","readme":"Table of Contents\n=================\n\n* [String Repeat](#string-repeat)\n  * [Install](#install)\n  * [Usage](#usage)\n  * [Benchmark](#benchmark)\n  * [Source](#source)\n  * [Developer](#developer)\n    * [Test](#test)\n    * [Cover](#cover)\n    * [Lint](#lint)\n    * [Clean](#clean)\n    * [Readme](#readme)\n\nString Repeat\n=============\n\n[\u003cimg src=\"https://travis-ci.org/tmpfs/string-repeater.svg?v=2\" alt=\"Build Status\"\u003e](https://travis-ci.org/tmpfs/string-repeater)\n[\u003cimg src=\"http://img.shields.io/npm/v/string-repeater.svg?v=2\" alt=\"npm version\"\u003e](https://npmjs.org/package/string-repeater)\n[\u003cimg src=\"https://coveralls.io/repos/tmpfs/string-repeater/badge.svg?branch=master\u0026service=github\u0026v=2\" alt=\"Coverage Status\"\u003e](https://coveralls.io/github/tmpfs/string-repeater?branch=master).\n\nRepeat a string.\n\n## Install\n\n```\nnpm i string-repeater --save\n```\n\n## Usage\n\n```javascript\nvar repeat = require('string-repeater')\n  , str = repeat('foo ', 7);\n// 'foo foo foo foo foo '\n```\n\nOr if you prefer to polyfill `String.prototype`:\n\n```javascript\nvar repeat = require('string-repeater');\nString.prototype.repeat = String.prototype.repeat || repeat.impl;\n```\n\n## Benchmark\n\n```javascript\nstring-repeater x 4,439,603 ops/sec ±2.15% (85 runs sampled)\nstring-repeat x 60,621 ops/sec ±4.63% (81 runs sampled)\nstring.prototype.repeat x 4,071,996 ops/sec ±2.14% (84 runs sampled)\n```\n\n## Source\n\n```javascript\n\"use strict\"\n\n/**\n *  Repeat a string.\n *\n *  @param input The string to repeat.\n *  @param times The number of times to repeat.\n *\n *  @return A new repeated string.\n */\nfunction repeat(input, times) {\n  return impl.call(input, times);\n}\n\n/**\n *  Prototype implementation called with the string as the scope.\n *\n *  Note that this implementation:\n *\n *  return new Array(Math.abs(times) + 1).join(this);\n *\n *  Is very, very slow.\n *\n *  This implementation:\n *\n *  var ret = '';\n *  for(var i = 0; i \u003c times; i++) {\n *    ret += this;\n *  }\n *  return ret;\n *\n *  Is faster than `string-repeat` but slower than `string.prototype.repeat`.\n *\n *  @param times The number of times to repeat.\n *\n *  @return A new repeated string.\n */\nfunction impl(times) {\n  // conditional is faster than Math.abs()\n  var n = times \u003c 0 ? -times : times\n    , result = ''\n    , string = '' + this;\n  // optimized loop from string.prototype.repeat\n  while(n) {\n    if(n % 2 === 1) {\n      result += string;\n    }\n    if(n \u003e 1) {\n      string += string;\n    }\n    n \u003e\u003e= 1;\n  }\n  return result;\n}\n\nrepeat.impl = impl;\n\nmodule.exports = repeat;\n```\n\n## Developer\n\n### Test\n\nTo run the test suite:\n\n```\nnpm test\n```\n\n### Cover\n\nTo generate code coverage run:\n\n```\nnpm run cover\n```\n\n### Lint\n\nRun the source tree through [jshint](http://jshint.com) and [jscs](http://jscs.info):\n\n```\nnpm run lint\n```\n\n### Clean\n\nRemove generated files:\n\n```\nnpm run clean\n```\n\n### Readme\n\nTo build the readme file from the partial definitions:\n\n```\nnpm run readme\n```\n\nGenerated by [mdp(1)](https://github.com/tmpfs/mdp).\n\n[jshint]: http://jshint.com\n[jscs]: http://jscs.info\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmpfs%2Fstring-repeater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmpfs%2Fstring-repeater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmpfs%2Fstring-repeater/lists"}