-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
5,969 additions
and
8,684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: mesqueeb | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: main | ||
paths: | ||
- src/** | ||
- test/** | ||
- '*.js' | ||
- '*.ts' | ||
- '*.json' | ||
- .github/workflows/test.yml | ||
pull_request: | ||
branches: main | ||
paths: | ||
- src/** | ||
- test/** | ||
- '*.js' | ||
- '*.ts' | ||
- '*.json' | ||
- .github/workflows/test.yml | ||
concurrency: | ||
group: test-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
node-version: ['18', '20'] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
- run: npm ci | ||
- run: npm test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import prettier from "@cycraft/eslint/prettier" | ||
|
||
export default prettier |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,48 @@ | ||
function roll(minOrMax, max) { | ||
let _min = 0, _max = 100; | ||
if (minOrMax === void 0) ; else if (max === void 0) { | ||
_min = 0; | ||
_max = minOrMax; | ||
} else { | ||
_min = minOrMax; | ||
_max = max; | ||
} | ||
return Math.floor(Math.random() * (_max - _min + 1)) + _min; | ||
/** | ||
* Roll any number. When passing no arguments it returns a number between 0 - 100; including 0 and 100 | ||
* @param {number} [minOrMax] When passing only 1 argument it returns a number between 0 and the argument; including 0 and the argument | ||
* @param {number} [max] When passing 2 arguments, they are considered "min" and "max"; it returns a number between min - max; including min and max | ||
* @returns {number} | ||
*/ | ||
export function roll(minOrMax, max) { | ||
let _min = 0; | ||
let _max = 100; | ||
if (minOrMax === void 0) { | ||
// keep 0 - 100 | ||
} | ||
else if (max === void 0) { | ||
_min = 0; | ||
_max = minOrMax; | ||
} | ||
else { | ||
_min = minOrMax; | ||
_max = max; | ||
} | ||
return Math.floor(Math.random() * (_max - _min + 1)) + _min; | ||
} | ||
function flip() { | ||
return roll(1) === 0 ? "heads" : "tails"; | ||
/** | ||
* Returns 'heads' or 'tails' at random | ||
* @returns {'heads' | 'tails'} | ||
*/ | ||
export function flip() { | ||
return roll(1) === 0 ? 'heads' : 'tails'; | ||
} | ||
function Dice(sides = 6) { | ||
return { | ||
sides, | ||
roll() { | ||
return roll(1, this.sides); | ||
}, | ||
rollAssert(targetNumber) { | ||
return roll(1, this.sides) === targetNumber; | ||
} | ||
}; | ||
/** | ||
* Create a dice with any number of sides, dice(6).roll() to roll it! | ||
* You can also try rolling a specific side to return a boolean like so: dice(6).rollAssert(6). | ||
* | ||
* @export | ||
* @param {?number} [sides=6] The number of sides | ||
* @returns {{ sides: number, roll: () => number, rollAssert: (target: number) => boolean }} | ||
*/ | ||
export function Dice(sides = 6) { | ||
return { | ||
sides, | ||
roll() { | ||
return roll(1, this.sides); | ||
}, | ||
rollAssert(targetNumber) { | ||
return roll(1, this.sides) === targetNumber; | ||
}, | ||
}; | ||
} | ||
|
||
export { Dice, flip, roll }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import config from '@cycraft/eslint/config' | ||
|
||
export default config |
Oops, something went wrong.