pax_global_header00006660000000000000000000000064140440442500014507gustar00rootroot0000000000000052 comment=f4ab25a9a7dfbdfb5f61b514406a5ba2487be0dd repeating-4.0.0/000077500000000000000000000000001404404425000134665ustar00rootroot00000000000000repeating-4.0.0/.editorconfig000066400000000000000000000002571404404425000161470ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 repeating-4.0.0/.gitattributes000066400000000000000000000000231404404425000163540ustar00rootroot00000000000000* text=auto eol=lf repeating-4.0.0/.github/000077500000000000000000000000001404404425000150265ustar00rootroot00000000000000repeating-4.0.0/.github/funding.yml000066400000000000000000000001631404404425000172030ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/repeating custom: https://sindresorhus.com/donate repeating-4.0.0/.github/security.md000066400000000000000000000002631404404425000172200ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. repeating-4.0.0/.github/workflows/000077500000000000000000000000001404404425000170635ustar00rootroot00000000000000repeating-4.0.0/.github/workflows/main.yml000066400000000000000000000006641404404425000205400ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 16 - 14 - 12 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test repeating-4.0.0/.gitignore000066400000000000000000000000271404404425000154550ustar00rootroot00000000000000node_modules yarn.lock repeating-4.0.0/.npmrc000066400000000000000000000000231404404425000146010ustar00rootroot00000000000000package-lock=false repeating-4.0.0/index.js000066400000000000000000000010031404404425000151250ustar00rootroot00000000000000export default function repeating(count, repeatString = ' ') { if (typeof repeatString !== 'string') { throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof repeatString}\``); } if (count < 0 || !Number.isFinite(count)) { throw new TypeError(`Expected \`count\` to be a positive finite number, got \`${count}\``); } let returnValue = ''; do { if (count & 1) { returnValue += repeatString; } repeatString += repeatString; } while ((count >>= 1)); return returnValue; } repeating-4.0.0/license000066400000000000000000000021351404404425000150340ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. repeating-4.0.0/package.json000066400000000000000000000011541404404425000157550ustar00rootroot00000000000000{ "name": "repeating", "version": "4.0.0", "description": "Repeat a string - fast", "license": "MIT", "repository": "sindresorhus/repeating", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "engines": { "node": ">=12" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "repeat", "string", "repeating", "text", "fill", "pad" ], "devDependencies": { "ava": "^3.15.0", "xo": "^0.39.1" } } repeating-4.0.0/readme.md000066400000000000000000000036531404404425000152540ustar00rootroot00000000000000# repeating > Repeat a string - fast **This module is moot now. Just use [`String#repeat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).** ## Install ``` $ npm install repeating ``` ## Usage ```js import repeating from 'repeating'; repeating(5); //=> ' ' repeating(100, 'unicorn '); //=> 'unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn ' ``` ## API ### repeating(count, string?) #### count Type: `number` Times the `string` should be repeated. #### string Type: `string`\ Default: `' '` String to repeat. ## Related - [repeating-cli](https://github.com/sindresorhus/repeating-cli) - CLI for this module - [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string ---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
repeating-4.0.0/test.js000066400000000000000000000007651404404425000150130ustar00rootroot00000000000000import test from 'ava'; import repeating from './index.js'; test('error', t => { t.throws(() => { repeating(5, 5); }, { message: 'Expected `input` to be a `string`, got `number`' }); t.throws(() => { repeating(-5, 'foo'); }, { message: 'Expected `count` to be a positive finite number, got `-5`' }); }); test('repeating', t => { t.is(repeating(5), ' '); t.is(repeating(5, ''), ''); t.is(repeating(5, 'a'), 'aaaaa'); t.is(repeating(3, 'unicorn'), 'unicornunicornunicorn'); });