pax_global_header00006660000000000000000000000064130031654520014511gustar00rootroot0000000000000052 comment=4398e75c25f694eae2052cd3d108d6b04913492c repeat-string-1.6.1/000077500000000000000000000000001300316545200143025ustar00rootroot00000000000000repeat-string-1.6.1/.editorconfig000066400000000000000000000004051300316545200167560ustar00rootroot00000000000000root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [{**/{actual,fixtures,expected,templates}/**,*.md}] trim_trailing_whitespace = false insert_final_newline = falserepeat-string-1.6.1/.eslintrc.json000066400000000000000000000071251300316545200171030ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], "brace-style": [2, "1tbs", { "allowSingleLine": true }], "comma-dangle": [2, "never"], "comma-spacing": [2, { "before": false, "after": true }], "comma-style": [2, "last"], "constructor-super": 2, "curly": [2, "multi-line"], "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], "handle-callback-err": [2, "^(err|error)$" ], "indent": [2, 2, { "SwitchCase": 1 }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [2, "functions"], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [2, { "max": 1 }], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "no-useless-call": 0, "no-with": 2, "one-var": [0, { "initialized": "never" }], "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], "padded-blocks": [0, "never"], "quotes": [2, "single", "avoid-escape"], "radix": 2, "semi": [2, "always"], "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], "yoda": [2, "never"] } } repeat-string-1.6.1/.gitattributes000066400000000000000000000001771300316545200172020ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binaryrepeat-string-1.6.1/.gitignore000066400000000000000000000003311300316545200162670ustar00rootroot00000000000000# always ignore files *.DS_Store *.sublime-* # test related, or directories generated by tests test/actual actual coverage # npm node_modules npm-debug.log # misc _gh_pages bower_components vendor temp tmp TODO.md repeat-string-1.6.1/.travis.yml000066400000000000000000000001541300316545200164130ustar00rootroot00000000000000sudo: false os: - linux - osx language: node_js node_js: - node - '6' - '5' - '0.12' - '0.10' repeat-string-1.6.1/.verb.md000066400000000000000000000004731300316545200156440ustar00rootroot00000000000000## Usage {%= apidocs("index.js") %} ## Benchmarks Repeat string is significantly faster than the native method (which is itself faster than [repeating](https://github.com/sindresorhus/repeating)): ```sh {%= bench() %} ``` **Run the benchmarks** Install dev dependencies: ```sh npm i -d && node benchmark ``` repeat-string-1.6.1/LICENSE000066400000000000000000000021001300316545200153000ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2015, Jon Schlinkert. 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. repeat-string-1.6.1/README.md000066400000000000000000000117011300316545200155610ustar00rootroot00000000000000# repeat-string [![NPM version](https://img.shields.io/npm/v/repeat-string.svg?style=flat)](https://www.npmjs.com/package/repeat-string) [![NPM monthly downloads](https://img.shields.io/npm/dm/repeat-string.svg?style=flat)](https://npmjs.org/package/repeat-string) [![NPM total downloads](https://img.shields.io/npm/dt/repeat-string.svg?style=flat)](https://npmjs.org/package/repeat-string) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/repeat-string.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/repeat-string) > Repeat the given string n times. Fastest implementation for repeating a string. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save repeat-string ``` ## Usage ### [repeat](index.js#L41) Repeat the given `string` the specified `number` of times. **Example:** **Example** ```js var repeat = require('repeat-string'); repeat('A', 5); //=> AAAAA ``` **Params** * `string` **{String}**: The string to repeat * `number` **{Number}**: The number of times to repeat the string * `returns` **{String}**: Repeated string ## Benchmarks Repeat string is significantly faster than the native method (which is itself faster than [repeating](https://github.com/sindresorhus/repeating)): ```sh # 2x repeat-string █████████████████████████ (26,953,977 ops/sec) repeating █████████ (9,855,695 ops/sec) native ██████████████████ (19,453,895 ops/sec) # 3x repeat-string █████████████████████████ (19,445,252 ops/sec) repeating ███████████ (8,661,565 ops/sec) native ████████████████████ (16,020,598 ops/sec) # 10x repeat-string █████████████████████████ (23,792,521 ops/sec) repeating █████████ (8,571,332 ops/sec) native ███████████████ (14,582,955 ops/sec) # 50x repeat-string █████████████████████████ (23,640,179 ops/sec) repeating █████ (5,505,509 ops/sec) native ██████████ (10,085,557 ops/sec) # 250x repeat-string █████████████████████████ (23,489,618 ops/sec) repeating ████ (3,962,937 ops/sec) native ████████ (7,724,892 ops/sec) # 2000x repeat-string █████████████████████████ (20,315,172 ops/sec) repeating ████ (3,297,079 ops/sec) native ███████ (6,203,331 ops/sec) # 20000x repeat-string █████████████████████████ (23,382,915 ops/sec) repeating ███ (2,980,058 ops/sec) native █████ (5,578,808 ops/sec) ``` **Run the benchmarks** Install dev dependencies: ```sh npm i -d && node benchmark ``` ## About ### Related projects [repeat-element](https://www.npmjs.com/package/repeat-element): Create an array by repeating the given value n times. | [homepage](https://github.com/jonschlinkert/repeat-element "Create an array by repeating the given value n times.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Contributors | **Commits** | **Contributor**
| | --- | --- | | 51 | [jonschlinkert](https://github.com/jonschlinkert) | | 2 | [LinusU](https://github.com/LinusU) | | 2 | [tbusser](https://github.com/tbusser) | | 1 | [doowb](https://github.com/doowb) | | 1 | [wooorm](https://github.com/wooorm) | ### Building docs _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ To generate the readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm install -g verb verb-generate-readme && verb ``` ### Running tests Install dev dependencies: ```sh $ npm install -d && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ### License Copyright © 2016, [Jon Schlinkert](http://github.com/jonschlinkert). Released under the [MIT license](https://github.com/jonschlinkert/repeat-string/blob/master/LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 23, 2016._repeat-string-1.6.1/benchmark/000077500000000000000000000000001300316545200162345ustar00rootroot00000000000000repeat-string-1.6.1/benchmark/code/000077500000000000000000000000001300316545200171465ustar00rootroot00000000000000repeat-string-1.6.1/benchmark/code/add.js000066400000000000000000000011221300316545200202300ustar00rootroot00000000000000module.exports = repeat; function repeat(str, num) { if (typeof str !== 'string') { throw new TypeError('repeat-string expects a string.'); } var len = str.length; var max = len * num; if (num === 1 || len === max) return str; if (num === 2) return str + str; if (cache !== str || typeof cache === 'undefined') { res = cache = str; num--; } var rlen = res.length; while (max > rlen && num > 0) { if (num & 1) { res += str; } num >>= 1; str += str; } return res.substr(0, max); } /** * Results cache */ var res = ''; var cache; repeat-string-1.6.1/benchmark/code/array.js000066400000000000000000000001671300316545200206260ustar00rootroot00000000000000'use strict'; module.exports = function repeat(str, num) { var arr = []; arr[num] = ''; return arr.join(str); };repeat-string-1.6.1/benchmark/code/for-bitwise.js000066400000000000000000000003331300316545200217350ustar00rootroot00000000000000'use strict'; module.exports = repeat; function repeat(str, num) { var res = ''; for (;;) { if (num & 1) { res += str; } num >>>= 1; if (!num) return res; str += str; } return res; }repeat-string-1.6.1/benchmark/code/for-join.js000077500000000000000000000002421300316545200212300ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, num) { num += 1; var arr; for (arr = []; 0 < num; num -= 1, arr[num] = ''); return arr.join(val); }; repeat-string-1.6.1/benchmark/code/for-str-cache-2.js000077500000000000000000000007511300316545200223060ustar00rootroot00000000000000'use strict'; module.exports = repeat; var res = ''; var cache; function repeat(str, num) { cache = cache || str; if (cache !== str) { res = ''; cache = str; } var max = (str.length * num); var i = 0; if (res.length >= max) { return res.slice(0, max); } for (; num > 0; i++) { if (num & 1) { res += str; } if (res.length >= max) { return res.slice(0, max); } num >>= 1; str += str; } return res.slice(0, max); } repeat-string-1.6.1/benchmark/code/for-str-cache.js000077500000000000000000000006541300316545200221510ustar00rootroot00000000000000'use strict'; var res = ''; var cache; module.exports = function repeat(str, count) { var max = (str.length * count); var i = 0; cache = cache || str; if (cache !== str) { res = ''; cache = str; } if (res.length >= max) { return res.slice(0, max); } for (; i < count; i++) { res += str; if (res.length >= max) { return res.slice(0, max); } } return res.slice(0, max); }; repeat-string-1.6.1/benchmark/code/for-str.js000077500000000000000000000002311300316545200210770ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, amount) { var res = ''; for (var i = 0; i < amount; i++) { res += val; } return res; }; repeat-string-1.6.1/benchmark/code/native.js000066400000000000000000000001311300316545200207650ustar00rootroot00000000000000'use strict'; module.exports = function repeat(str, num) { return str.repeat(num); }; repeat-string-1.6.1/benchmark/code/new-array-for.js000077500000000000000000000002571300316545200222040ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, amount) { for (var i = 0, res = new Array(amount); i < amount + 1;) { res[i++] = ''; } return res.join(val); }; repeat-string-1.6.1/benchmark/code/new-array-join.js000077500000000000000000000002171300316545200223510ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, num) { if (arguments.length === 1) return ''; return new Array(num + 1).join(val); }; repeat-string-1.6.1/benchmark/code/repeat-string-1.3.0.js000077500000000000000000000006451300316545200227350ustar00rootroot00000000000000'use strict'; var res = ''; var cache; module.exports = function repeat(str, num) { var max = str.length * num; cache = cache || str; if (cache !== str) { res = ''; cache = str; } while (num > 0 && max > res.length) { if (num & 1) { res += str; } if (max <= res.length) { return res.substr(0, max); } num >>= 1; str += str; } return res.substr(0, max); }; repeat-string-1.6.1/benchmark/code/repeat-string-1.5.4.js000066400000000000000000000022041300316545200227310ustar00rootroot00000000000000/*! * repeat-string * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; /** * Results cache */ var res = ''; var cache; /** * Expose `repeat` */ module.exports = repeat; /** * Repeat the given `string` the specified `number` * of times. * * **Example:** * * ```js * var repeat = require('repeat-string'); * repeat('A', 5); * //=> AAAAA * ``` * * @param {String} `string` The string to repeat * @param {Number} `number` The number of times to repeat the string * @return {String} Repeated string * @api public */ function repeat(str, num) { if (typeof str !== 'string') { throw new TypeError('repeat-string expects a string.'); } // cover common, quick use cases if (num === 1) return str; if (num === 2) return str + str; var max = str.length * num; if (cache !== str || typeof cache === 'undefined') { cache = str; res = ''; } while (max > res.length && num > 0) { if (num & 1) { res += str; } num >>= 1; if (!num) break; str += str; } return res.substr(0, max); } repeat-string-1.6.1/benchmark/code/repeat-string.js000077500000000000000000000000611300316545200222700ustar00rootroot00000000000000'use strict'; module.exports = require('../..');repeat-string-1.6.1/benchmark/code/repeating.js000077500000000000000000000001751300316545200214700ustar00rootroot00000000000000'use strict'; var repeating = require('repeating'); module.exports = function(str, num) { return repeating(num, str); }; repeat-string-1.6.1/benchmark/code/unshift.js000077500000000000000000000002321300316545200211640ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, amount) { var res = []; while (amount--) { res.unshift(val); } return res.join(''); }; repeat-string-1.6.1/benchmark/code/while-array-1.js000077500000000000000000000002171300316545200220710ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, num) { var arr = []; while (num--) { arr[num] = val; } return arr.join(''); };repeat-string-1.6.1/benchmark/code/while-array-2.js000077500000000000000000000002351300316545200220720ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, num) { var arr = []; var i = 0; while (num--) { arr[i++] = val; } return arr.join(''); };repeat-string-1.6.1/benchmark/code/while-array-3.js000077500000000000000000000002731300316545200220750ustar00rootroot00000000000000'use strict'; module.exports = function(val, num) { return repeat(val, num, []).join(''); }; function repeat(val, num, arr) { while (num--) { arr[num] = val; } return arr; }repeat-string-1.6.1/benchmark/code/while-bitwise.js000066400000000000000000000003421300316545200222570ustar00rootroot00000000000000'use strict'; module.exports = repeat; function repeat(str, num) { var res = ''; while (num > 0) { if (num & 1) { res += str; } num >>>= 1; if (!num) return res; str += str; } return res; }repeat-string-1.6.1/benchmark/code/while-square-root.js000066400000000000000000000003631300316545200230750ustar00rootroot00000000000000'use strict'; module.exports = function repeat(str, num) { var max = str.length * num; num = Math.ceil(Math.sqrt(num)); while (num--) { str += str; if (str.length > max) { break; } } return str.slice(0, max); };repeat-string-1.6.1/benchmark/code/while-str-stack.js000066400000000000000000000003201300316545200225200ustar00rootroot00000000000000'use strict'; module.exports = function repeat(str, num) { var max = str.length * num; while (num--) { str += str; if (str.length >= max) { break; } } return str.slice(0, max); };repeat-string-1.6.1/benchmark/code/while-str.js000077500000000000000000000002101300316545200214160ustar00rootroot00000000000000'use strict'; module.exports = function repeat(val, amount) { var str = ''; while (amount--) { str += val; } return str; };repeat-string-1.6.1/benchmark/code/while.js000077500000000000000000000003111300316545200206120ustar00rootroot00000000000000'use strict'; module.exports = function repeat(str, count) { var res = ''; while (count > 0) { if (count & 1) { res += str; } count >>= 1; str += str; } return res; }; repeat-string-1.6.1/benchmark/fixtures/000077500000000000000000000000001300316545200201055ustar00rootroot00000000000000repeat-string-1.6.1/benchmark/fixtures/0.js000077500000000000000000000000531300316545200206030ustar00rootroot00000000000000'use strict'; module.exports = ['afa', 0];repeat-string-1.6.1/benchmark/fixtures/1.js000077500000000000000000000000531300316545200206040ustar00rootroot00000000000000'use strict'; module.exports = ['abc', 1];repeat-string-1.6.1/benchmark/fixtures/10.js000066400000000000000000000000561300316545200206640ustar00rootroot00000000000000'use strict'; module.exports = ['abcabc', 5];repeat-string-1.6.1/benchmark/fixtures/100.js000077500000000000000000000000571300316545200207500ustar00rootroot00000000000000'use strict'; module.exports = ['fas', 100]; repeat-string-1.6.1/benchmark/fixtures/2.js000066400000000000000000000000531300316545200206020ustar00rootroot00000000000000'use strict'; module.exports = ['def', 2];repeat-string-1.6.1/benchmark/fixtures/2000.js000077500000000000000000000000601300316545200210230ustar00rootroot00000000000000'use strict'; module.exports = ['lll', 2000]; repeat-string-1.6.1/benchmark/fixtures/20000.js000066400000000000000000000000611300316545200211010ustar00rootroot00000000000000'use strict'; module.exports = ['lll', 20000]; repeat-string-1.6.1/benchmark/fixtures/25.js000077500000000000000000000000541300316545200206730ustar00rootroot00000000000000'use strict'; module.exports = ['iai', 25];repeat-string-1.6.1/benchmark/fixtures/250.js000077500000000000000000000000571300316545200207560ustar00rootroot00000000000000'use strict'; module.exports = ['bbb', 250]; repeat-string-1.6.1/benchmark/fixtures/3.js000066400000000000000000000000531300316545200206030ustar00rootroot00000000000000'use strict'; module.exports = ['ghi', 3];repeat-string-1.6.1/benchmark/fixtures/4.js000066400000000000000000000000531300316545200206040ustar00rootroot00000000000000'use strict'; module.exports = ['xyz', 4];repeat-string-1.6.1/benchmark/fixtures/5.js000077500000000000000000000000531300316545200206100ustar00rootroot00000000000000'use strict'; module.exports = ['fff', 5];repeat-string-1.6.1/benchmark/fixtures/50.js000077500000000000000000000000561300316545200206730ustar00rootroot00000000000000'use strict'; module.exports = ['xyz', 50]; repeat-string-1.6.1/benchmark/helper.js000066400000000000000000000040051300316545200200500ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var repeat = require('repeat-string'); var isObject = require('isobject'); var text = require('text-table'); var table = []; function bench() { var filepath = path.join(__dirname, 'last.md'); var str = fs.readFileSync(filepath, 'utf8'); var sections = str.split(/\n(?=\n?(?:# benchmark))/); sections.shift(); var len = sections.length; var idx = -1; var res = []; while (++idx < len) { parseSection(sections[idx].trim()); } return text(table); } function parseSection(str) { var lines = str.split('\n').filter(Boolean); lines.pop(); if (!lines.length) return; var heading = lines.shift().trim(); var m = /^.*\/fixtures\/([^(]+)/.exec(heading); var title = (m ? m[1] : heading).trim(); var tok = {title: title}; tok.title = path.basename(title, path.extname(title)) + 'x'; return createLines(tok, lines); } function createLines(tok, lines) { var len = lines.length; var idx = -1; while (++idx < len) { var line = lines[idx]; var obj = parseStats(line); tok[obj.name] = obj; } var vals = values(tok); var max = Math.max.apply(Math, vals); table.push([], ['# ' + tok.title]) for (var key in tok) { if (tok.hasOwnProperty(key)) { if (isObject(tok[key])) { table.push(format(tok[key], max, 100)); } } } } function format(tok, max, diff) { return [tok.name.trim(), bar(tok, max, diff).trim(), '(' + tok.val + ' ops/sec)']; } function parseStats(line) { var str = line.trim(); var m = /^([^ ]+) x ([\d,.]+)/.exec(str); var tok = {num: 0, val: ''}; if (!m) return tok; tok.name = m[1]; tok.val = m[2]; tok.num = String(tok.val).split(',').join(''); return tok; } function values(obj) { var vals = []; for (var key in obj) { if (key === 'title') continue; vals.push(obj[key].num); } return vals; } function bar(tok, longest) { return repeat('█', (tok.num / longest) * 25); } /** * Expose `.bench` helper */ module.exports.bench = bench; repeat-string-1.6.1/benchmark/index.js000077500000000000000000000013601300316545200177040ustar00rootroot00000000000000'use strict'; var util = require('util'); var cyan = require('ansi-cyan'); var argv = require('yargs-parser')(process.argv.slice(2)); var Suite = require('benchmarked'); var suite = new Suite({ cwd: __dirname, fixtures: 'fixtures/{2,3,10,50,250,2000,20000}.js', code: 'code/{repeat-string,repeating,native}.js' }); if (argv.dry) { console.log(); suite.dryRun(function(code, fixture) { console.log(cyan('%s > %s'), code.key, fixture.key); var args = require(fixture.path); var res = code.run.apply(null, args); console.log(util.inspect(res, {depth: null})); if (Array.isArray(res)) { console.log(); console.log(cyan(' total:'), res.length, 'items'); } console.log(); }); } else { suite.run(); } repeat-string-1.6.1/benchmark/last.md000066400000000000000000000033351300316545200175250ustar00rootroot00000000000000Benchmarking: (7 of 7) · 2 · 3 · 10 · 50 · 250 · 2000 · 20000 # benchmark/fixtures/2.js (43 B) repeat-string x 26,953,977 ops/sec ±0.53% (86 runs sampled) repeating x 9,855,695 ops/sec ±1.06% (89 runs sampled) native x 19,453,895 ops/sec ±1.24% (84 runs sampled) fastest is repeat-string # benchmark/fixtures/3.js (43 B) repeat-string x 19,445,252 ops/sec ±0.68% (89 runs sampled) repeating x 8,661,565 ops/sec ±0.94% (89 runs sampled) native x 16,020,598 ops/sec ±0.84% (87 runs sampled) fastest is repeat-string # benchmark/fixtures/10.js (46 B) repeat-string x 23,792,521 ops/sec ±0.47% (91 runs sampled) repeating x 8,571,332 ops/sec ±1.33% (90 runs sampled) native x 14,582,955 ops/sec ±0.86% (89 runs sampled) fastest is repeat-string # benchmark/fixtures/50.js (46 B) repeat-string x 23,640,179 ops/sec ±0.72% (89 runs sampled) repeating x 5,505,509 ops/sec ±1.01% (90 runs sampled) native x 10,085,557 ops/sec ±0.84% (89 runs sampled) fastest is repeat-string # benchmark/fixtures/250.js (47 B) repeat-string x 23,489,618 ops/sec ±0.98% (88 runs sampled) repeating x 3,962,937 ops/sec ±0.94% (92 runs sampled) native x 7,724,892 ops/sec ±0.75% (90 runs sampled) fastest is repeat-string # benchmark/fixtures/2000.js (48 B) repeat-string x 20,315,172 ops/sec ±0.78% (90 runs sampled) repeating x 3,297,079 ops/sec ±0.91% (92 runs sampled) native x 6,203,331 ops/sec ±0.84% (89 runs sampled) fastest is repeat-string # benchmark/fixtures/20000.js (49 B) repeat-string x 23,382,915 ops/sec ±0.67% (88 runs sampled) repeating x 2,980,058 ops/sec ±0.73% (89 runs sampled) native x 5,578,808 ops/sec ±0.79% (89 runs sampled) fastest is repeat-string repeat-string-1.6.1/bower.json000066400000000000000000000014511300316545200163140ustar00rootroot00000000000000{ "name": "repeat-string", "description": "Repeat the given string n times. Fastest implementation for repeating a string.", "repository": "jonschlinkert/repeat-string", "license": "MIT", "homepage": "https://github.com/jonschlinkert/repeat-string", "authors": [ "Jon Schlinkert (http://github.com/jonschlinkert)" ], "main": [ "index.js" ], "devDependencies": { "benchmarked": "^0.1.5", "chalk": "^1.1.1", "glob": "^7.0.0", "gulp-format-md": "^0.1.7", "mocha": "^2.4.5", "repeating": "^2.0.0", "should": "^8.2.2" }, "keywords": [ "fast", "fastest", "fill", "left", "left-pad", "multiple", "pad", "padding", "repeat", "repeating", "repetition", "right", "right-pad", "string", "times" ] }repeat-string-1.6.1/component.json000066400000000000000000000010221300316545200171720ustar00rootroot00000000000000{ "name": "repeat-string", "description": "Repeat the given string n times. Fastest implementation for repeating a string.", "version": "1.5.0", "repository": "https://github.com/jonschlinkert/repeat-string", "license": "MIT", "main": "index.js", "scripts": [ "index.js" ], "keywords": [ "fast", "fastest", "fill", "left", "left-pad", "multiple", "pad", "padding", "repetition", "repeat", "repeating", "right", "right-pad", "string", "times" ] } repeat-string-1.6.1/index.js000066400000000000000000000022751300316545200157550ustar00rootroot00000000000000/*! * repeat-string * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; /** * Results cache */ var res = ''; var cache; /** * Expose `repeat` */ module.exports = repeat; /** * Repeat the given `string` the specified `number` * of times. * * **Example:** * * ```js * var repeat = require('repeat-string'); * repeat('A', 5); * //=> AAAAA * ``` * * @param {String} `string` The string to repeat * @param {Number} `number` The number of times to repeat the string * @return {String} Repeated string * @api public */ function repeat(str, num) { if (typeof str !== 'string') { throw new TypeError('expected a string'); } // cover common, quick use cases if (num === 1) return str; if (num === 2) return str + str; var max = str.length * num; if (cache !== str || typeof cache === 'undefined') { cache = str; res = ''; } else if (res.length >= max) { return res.substr(0, max); } while (max > res.length && num > 1) { if (num & 1) { res += str; } num >>= 1; str += str; } res += str; res = res.substr(0, max); return res; } repeat-string-1.6.1/package.json000066400000000000000000000033031300316545200165670ustar00rootroot00000000000000{ "name": "repeat-string", "description": "Repeat the given string n times. Fastest implementation for repeating a string.", "version": "1.6.1", "homepage": "https://github.com/jonschlinkert/repeat-string", "author": "Jon Schlinkert (http://github.com/jonschlinkert)", "contributors": [ "Brian Woodward (https://github.com/doowb)", "Jon Schlinkert (http://twitter.com/jonschlinkert)", "Linus Unnebäck (http://linus.unnebäck.se)", "Thijs Busser (http://tbusser.net)", "Titus (wooorm.com)" ], "repository": "jonschlinkert/repeat-string", "bugs": { "url": "https://github.com/jonschlinkert/repeat-string/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10" }, "scripts": { "test": "mocha" }, "devDependencies": { "ansi-cyan": "^0.1.1", "benchmarked": "^0.2.5", "gulp-format-md": "^0.1.11", "isobject": "^2.1.0", "mocha": "^3.1.2", "repeating": "^3.0.0", "text-table": "^0.2.0", "yargs-parser": "^4.0.2" }, "keywords": [ "fast", "fastest", "fill", "left", "left-pad", "multiple", "pad", "padding", "repeat", "repeating", "repetition", "right", "right-pad", "string", "times" ], "verb": { "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "related": { "list": [ "repeat-element" ] }, "helpers": [ "./benchmark/helper.js" ], "reflinks": [ "verb" ] } } repeat-string-1.6.1/test.js000066400000000000000000000043571300316545200156300ustar00rootroot00000000000000/*! * repeat-string * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; require('mocha'); var assert = require('assert'); var repeat = require('./'); describe('repeat', function() { it('should return an empty string when a number is not given:', function() { assert.equal(repeat('a'), ''); }); it('should return an empty string when zero or null is given as the number:', function() { assert.equal(repeat('', 0), ''); assert.equal(repeat('a', 0), ''); assert.equal(repeat('', null), ''); assert.equal(repeat('a', null), ''); }); it('should repeat the given string n times', function() { assert.equal(repeat(' ', 0), ''); assert.equal(repeat('a', 0), ''); assert.equal(repeat('a', 1), 'a'); assert.equal(repeat('a', 2), 'aa'); assert.equal(repeat('a', 3), 'aaa'); assert.equal(repeat(' ', 3), ' '); assert.equal(repeat('a ', 3), 'a a a '); assert.equal(repeat('a', 10), 'aaaaaaaaaa'); assert.equal(repeat('b ', 10), 'b b b b b b b b b b '); assert.equal(repeat('a ', 10), 'a a a a a a a a a a '); assert.equal(repeat('abc ', 25), 'abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc '); }); it('should allow the multiplier to be a string:', function() { assert.equal(repeat('a', '0'), ''); assert.equal(repeat('a', '1'), 'a'); assert.equal(repeat('a', '2'), 'aa'); assert.equal(repeat('a', '10'), 'aaaaaaaaaa'); assert.equal(repeat('b ', '10'), 'b b b b b b b b b b '); assert.equal(repeat('a ', '10'), 'a a a a a a a a a a '); }); it('should cache strings until the string changes:', function() { assert.equal(repeat('a', '5'), 'aaaaa'); assert.equal(repeat('b ', '5'), 'b b b b b '); assert.equal(repeat('a ', '5'), 'a a a a a '); assert.equal(repeat('c ', '5'), 'c c c c c '); assert.equal(repeat('a ', '5'), 'a a a a a '); assert.equal(repeat('b ', '5'), 'b b b b b '); }); it('should throw an error when no string is given:', function() { assert.throws(function() {repeat(10); }, /expected a string/); assert.throws(function() {repeat(null); }, /expected a string/); }); });