npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@odczynflnpm/autem-velit-similique

v1.0.0

Published

Roll is a node.js package for rolling dice and adding modifiers (such as "2d6+1").

Downloads

10

Maintainers

ducvinh101011zducvinh101011z

Keywords

uprouteparsemapoffsetIteratorvaluesoptimistpackage managersomecompilerTypeBoxawaitieexecvalidestreepropertyCSSStyleDeclarationurlString.prototype.matchAllpushObjectjestconcatcontainstrimtc39Object.iscryptocloudsearchtscolumnReactiveXPushes2017scheme-validationapiInt16ArraywarningchaiUint16Arraywidthes2015promisesaccessordomcommand-linefindLastextensiongetterwordbreakkoreanpostcss-pluginfseventscss variablearraybufferequaltoolkitauthenticationArray.prototype.filterWeakMapSetstyled-componentssuperstructlengthschemaflatMapshamsyntaxpredictableawesomesaucetapRegExp#flagsUint32ArrayxhrMicrosoftsnsopenstoragegatewaybrowserdeep-copyserializationthrottlePromisewordwrapnamesdescriptorstypebundlerfsstylesReflect.getPrototypeOfliveastbddtestelectronqueueagenthotBigUint64Arrayutil.inspectES6Object.keysECMAScript 2019espreerandomchromiumtoStringTagrfc4122writablesortecmascripttapeURLiteratorminimaldeterministicworkspace:*validateRxJSrm -rfread256weakmapArray.prototype.containsRegExp.prototype.flagsefficientmonorepoexpressionterminalswfwhichenumerablecollectionECMAScript 3Object.assignlinkES2019setnumberinvariantES5querystringelasticachedirectoryJSONArray.prototype.flatMapruntimetextbreakunicodettywritepromiseutilitiesfindLastIndexrequirepatchdotenvargumentajvargvlibphonenumberarrays$.extendformmapreduceconcatMaplockfilesymbolStreamsbundlingfindupJSON-SchemagroupByprotocol-buffersbindcoercibleclonedescriptiontrimLefttouchfast-deep-copycall-boundpnpm9streamdayjsregularshimcommanderES3definePropertywatchFilewalkcss nestingtoSortedes-abstracttypescriptmkdirjwtRxbufferspackages_.extendstartergradients css3bound.enves6tslibloadbalancingreadablestreamtaskcharacterkeyhookformdebuggerloadinglimitedpostcssaccessibilityfluxvalidationInt8ArrayartfilterentriesbatchelbhasOwnpreprocessorcheckamazonES8asciiimmutableObservableArrayBuffer#sliceES7ESfile systemmiddlewaresearchemitformsUint8ClampedArrayenderspinnersform-validationeslintstylesheetmime-dbObject.getPrototypeOfCSStakeasyncbyteLengthl10nstructuredClonemruserializeTypedArraycorslook-updeepcloneArrayBuffer.prototype.slicefindes2016debugprogressless.jseslintconfigimportexportproxyRFC-6455flagforEachECMAScript 2018zoddiffcloudtrailreadablepruneqsless compilercall-bindmkdirstrimEnddateec2elmes-shim APIlogwaftypeerrorECMAScript 2023listenerscensorObject.valuestermdropjavascriptintrinsicprototypelastclassescopytostringtagReactiveExtensionsjsdomisConcatSpreadableObject.entriesmetadataemrdynamodbapolloconcurrencystreams2schemebusyreact-testing-librarytypedarraysettercallcore-jsfastifyUnderscorepluginflagslimitarraynodejssymlinksES2021Symbolemojispeedcharactersmakecloudfrontratelimitqueryimmer0mobileinspectESnexta11yreduxrobustfixed-widthstringifyoutputhttpfunctionstestingsaferecursiveimportfast-cloneArray.prototype.flattensuperagentbootstrap lessdataViewpositivejsxAsyncIteratorreuseframeworkpackagedom-testing-libraryjQuerys3figletcurlcodesless cssECMAScript 6dependency managercomputed-typesowncryptguiditerationequalityfetchjasminecolourfast-deep-clonefastcloneidroutingmixinslesscssjsdifffullECMAScript 2017assertshrinkwrapsimpledbMaptraversepreserve-symlinkschinesetrimStartArrayBufferinferencermsymlinkclassnamesautheventsenvironmentcssclistreamsflattenflatpersistentgetoptindicatorvalueairbnbstatewatcherstyleeventEmitterponyfilldiridlecolorcomparecollection.es6propertiesloggeres2018east-asian-widthwatchingmkdirpStreames7removesetPrototypeOfextraredux-toolkitcolumnsomitbrowserslistrm -frpolyfillobjtoolsregular expressionswebiammulti-packagekinesises5regular expressionmimeviewvestsharedeslint-pluginBigInt64Arraycommandextenduninstallreact-hookscloudformationwgetredirectjapaneseES2017filedescriptorbeanstalkeslintpluginfullwidthformatECMAScript 7installerstdlibajaxzerolooklrudependenciestimedatastructurermdirsettingskarmabufferworkflowlessgetPrototypeOfiteratecallbackconsolereducechannelinternaljsslicemodulesassignprivateclass-validatornativeES2020parentswalkingkeysquotehardlinkseventDispatcherebsES2023URLSearchParamsprettyeveryvariablesqueueMicrotaskendpointyupmergetestermovegradients cssgetdeleteless mixinsredactpathdeepcopyreact-hook-formcode pointswrapfull-widthtypedasserts@@toStringTaglocationArrayHyBilazyratehooksFloat32ArrayECMAScript 2022String.prototype.trimcircularcacheassertionnested csssameValueZeroECMAScript 5dataviewresolveduplexautoprefixerperformanceuuidsesclassnamegraphqlcloudwatchprivate dataprotothroatjsonerrorFunction.prototype.namehttpslanguageStyleSheetcjkmake dir-0genericsinstallsequence[[Prototype]]__proto__utilisdeepmomentmatchesfast-copyutilitybytenamemodulesqsnodeECMAScript 2020joiexpressrapidencryptionhas-ownwhatwgmochanegative

Readme

roll

Roll is a node.js package for rolling dice and adding modifiers (such as "2d6+1").

NPM

build status

How To Use (From Shell)

Installation (via npm)

$ npm install -g roll

Usage

$ roll 2d6+3
9
$ roll d20
15
$ roll d%
99
$ roll -d 2d20
Dice: 13, 8
Total: 21
$ roll --detail 5d%
Dice: 45, 86, 86, 4, 72
Total: 293

How To Use (As Library)

Installation (via npm)

$ npm install roll

Usage

Get an instance of the library:

var Roll = require('roll'),
  roll = new Roll();

Rolling a single die:

var oneDie = roll.roll('d6');
console.log(oneDie.result); //random number between 1 and 6 (inclusive)

Rolling multiple dice:

var twoTwenties = roll.roll('2d20');
console.log(twoTwenties.result); //random number between 2 and 40 (inclusive)

Rolling multiple sets of dice:

var bunchOfDice = roll.roll('2d20+1d12');
console.log(bunchOfDice.result); //random number between 3 and 52 (inclusive)

Rolling a percentage:

var chance = roll.roll('d%'); //same as '1d100', 'd100', or '1d%'
console.log(chance.result); //random number between 1 and 100 (inclusive)

Simple calculation (+, -, *, /):

var attack = roll.roll('2d6+2');
console.log(attack.result); //random number between 3 and 8 (inclusive)

Seeing what was rolled, rather than the sum:

var yahtzee = roll.roll('5d6');
console.log(yahtzee.rolled); //yahtzee.rolled will return something like [5, 2, 4, 6, 1] rather than the sum

var blessedSneaker = roll.roll('2d20b1+1d4+5');
console.log(blessedSneaker.rolled); // blessedSneaker.rolled will return an array containing an array for each component that is a roll of the dice, in the order in which they occurred, e.g. [[19,3],[1]]

Getting the highest two dice of the set:

var pickBestTwo = roll.roll('6d20b2'); //roll 6 dice and give me the 2 highest
console.log(pickBestTwo.calculations[1]); //pickBestTwo.calculations[0] is the same as .result, .calculations[1] is prior to the sum operation

Processing rolls without parsing a string:

var attack = roll.roll({
    quantity: 2,
    sides: 6,
    transformations: [ //can list n-number of pipeline operations to perform on the result
      'sum', //take the array of rolled dice and sum them together
      ['add', 2] //add 2 to the sum
    ]
});
console.log(attack.result); //random number between 3 and 8 (inclusive)

Using custom transformations:

var dropOnes = function(results){
  return results.filter(function (result) {
    return result !== 1;
  });
};
var noOnes = roll.roll({
  quantity: 5,
  sides: 4,
  transformations: [
    dropOnes, // remove any 1s because we have teh lucky bootz
    'sum'
  ]
});

Using a custom seed:

var srand = require('srand'); //https://github.com/isaacs/node-srand (npm install srand)
srand.seed(1000);

roll = new Roll(function () {
  return srand.random();
});

console.log(roll.roll('2d6+5').result);

Validating user input:

var userInput = 'this isn\'t a valid roll',
  valid = roll.validate(userInput);

if (!valid) {
  console.error('"%s" is not a valid input string for node-roll!', userInput);
}

Credits

Inspired by Phillip Newton's Games::Dice.

License

MIT License

Author

Troy Goode ([email protected])