pax_global_header00006660000000000000000000000064127315715660014527gustar00rootroot0000000000000052 comment=384b58d0238676ab2c1b2f7e85852fad2c7477a0 repeating-3.0.0/000077500000000000000000000000001273157156600135055ustar00rootroot00000000000000repeating-3.0.0/.editorconfig000066400000000000000000000002761273157156600161670ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 repeating-3.0.0/.gitattributes000066400000000000000000000000141273157156600163730ustar00rootroot00000000000000* text=auto repeating-3.0.0/.gitignore000066400000000000000000000000151273157156600154710ustar00rootroot00000000000000node_modules repeating-3.0.0/.travis.yml000066400000000000000000000000671273157156600156210ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' repeating-3.0.0/index.js000066400000000000000000000007001273157156600151470ustar00rootroot00000000000000'use strict'; module.exports = (n, str) => { str = str === undefined ? ' ' : str; if (typeof str !== 'string') { throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``); } if (n < 0 || !Number.isFinite(n)) { throw new TypeError(`Expected \`count\` to be a positive finite number, got \`${n}\``); } let ret = ''; do { if (n & 1) { ret += str; } str += str; } while ((n >>= 1)); return ret; }; repeating-3.0.0/license000066400000000000000000000021371273157156600150550ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (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-3.0.0/package.json000066400000000000000000000011141273157156600157700ustar00rootroot00000000000000{ "name": "repeating", "version": "3.0.0", "description": "Repeat a string - fast", "license": "MIT", "repository": "sindresorhus/repeating", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "repeat", "string", "repeating", "str", "text", "fill", "pad" ], "devDependencies": { "ava": "*", "xo": "*" }, "xo": { "esnext": true } } repeating-3.0.0/readme.md000066400000000000000000000030561273157156600152700ustar00rootroot00000000000000# repeating [![Build Status](https://travis-ci.org/sindresorhus/repeating.svg?branch=master)](https://travis-ci.org/sindresorhus/repeating) > Repeat a string - fast ## Install ``` $ npm install --save repeating ``` ## Usage ```js const repeating = require('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 ## License MIT © [Sindre Sorhus](https://sindresorhus.com) repeating-3.0.0/test.js000066400000000000000000000006041273157156600150220ustar00rootroot00000000000000import test from 'ava'; import m from './'; test('error', t => { t.throws(() => m(5, 5), 'Expected `input` to be a `string`, got `number`'); t.throws(() => m(-5, 'foo'), 'Expected `count` to be a positive finite number, got `-5`'); }); test('repeating', t => { t.is(m(5), ' '); t.is(m(5, ''), ''); t.is(m(5, 'a'), 'aaaaa'); t.is(m(3, 'unicorn'), 'unicornunicornunicorn'); });