Skip to content

Commit

Permalink
[Release] 🎉 yay v8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Apr 24, 2021
1 parent 89994a3 commit d327e4c
Show file tree
Hide file tree
Showing 33 changed files with 253 additions and 55 deletions.
2 changes: 1 addition & 1 deletion bijou-min.js

Large diffs are not rendered by default.

26 changes: 19 additions & 7 deletions bijou.js
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,8 @@ export let gcd = (...ary) => {
}
}
};

export let round = (number = req("number"), amount = 1) =>
Math.round(number / amount) * amount;
/**
* Tests if two things are equal, like "thing === thing2" but it also works for dates and objects.
* @memberOf math
Expand All @@ -2686,6 +2687,8 @@ export let gcd = (...ary) => {
*/
export let equals = (a = req("any", "a"), b = req("any", "b")) => {
if (a === b) return true;
if (_$.typeOf(a) === "RegExp" && _$.typeOf(b) === "RegExp")
return String(a) === String(b);
if (a instanceof Date && b instanceof Date)
return a.getTime() === b.getTime();
if (!a || !b || (typeof a !== "object" && typeof b !== "object"))
Expand Down Expand Up @@ -2854,19 +2857,19 @@ export let primesTo = (num = req("number", "number")) => {
* console.log(_$.random(0, 100)); // e.g. 47
*/
export let random = (
max = req("number", "max"),
min = req("number", "min"),
max = 0,
round = true,
seed = Math.random(),
) => {
if (min > max) {
[min, max] = [max, min];
}
var out = seed * (max - min + 1) + min;
if (round) {
return Math.floor(seed * (max - min + 1) + min);
} else {
return Math.random() * (max - min + 1) + min;
out = Math.round(out);
}
return out;
};
/**
* Get a random number from a seed.
Expand Down Expand Up @@ -4128,7 +4131,7 @@ export let resize = async (
*/
export let htmlToImage = (
html = req("string", "html string"),
{ x = 0, y = 0, width = 300, height = 400 },
{ x = 0, y = 0, width = 300, height = 400 } = {},
) => {
node();
let canvas = document.createElement("canvas");
Expand Down Expand Up @@ -4269,7 +4272,16 @@ export let race = (
* @param {Boolean} lowerCase Whether to return the string lowercased or not.
*/
export let typeOf = (e = req("any", "any"), lowerCase = true) =>
Object.prototype.toString.call(e).split(" ")[1].replace(/]$/, "");
lowerCase
? Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "")
.toLowerCase()
: Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "");
/**
* Injects CSS into the document head.
* @memberOf utility
Expand Down
27 changes: 20 additions & 7 deletions bijou_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,8 @@ let gcd = (...ary) => {
}
}
};

let round = (number = req("number"), amount = 1) =>
Math.round(number / amount) * amount;
/**
* Tests if two things are equal, like "thing === thing2" but it also works for dates and objects.
* @memberOf math
Expand All @@ -2632,6 +2633,8 @@ let gcd = (...ary) => {
*/
let equals = (a = req("any", "a"), b = req("any", "b")) => {
if (a === b) return true;
if (_$.typeOf(a) === "RegExp" && _$.typeOf(b) === "RegExp")
return String(a) === String(b);
if (a instanceof Date && b instanceof Date)
return a.getTime() === b.getTime();
if (!a || !b || (typeof a !== "object" && typeof b !== "object"))
Expand Down Expand Up @@ -2800,19 +2803,19 @@ let primesTo = (num = req("number", "number")) => {
* console.log(_$.random(0, 100)); // e.g. 47
*/
let random = (
max = req("number", "max"),
min = req("number", "min"),
max = 0,
round = true,
seed = Math.random(),
) => {
if (min > max) {
[min, max] = [max, min];
}
var out = seed * (max - min + 1) + min;
if (round) {
return Math.floor(seed * (max - min + 1) + min);
} else {
return Math.random() * (max - min + 1) + min;
out = Math.round(out);
}
return out;
};
/**
* Get a random number from a seed.
Expand Down Expand Up @@ -4074,7 +4077,7 @@ let resize = async (
*/
let htmlToImage = (
html = req("string", "html string"),
{ x = 0, y = 0, width = 300, height = 400 },
{ x = 0, y = 0, width = 300, height = 400 } = {},
) => {
node();
let canvas = document.createElement("canvas");
Expand Down Expand Up @@ -4167,7 +4170,16 @@ let race = (
* @param {Boolean} lowerCase Whether to return the string lowercased or not.
*/
let typeOf = (e = req("any", "any"), lowerCase = true) =>
Object.prototype.toString.call(e).split(" ")[1].replace(/]$/, "");
lowerCase
? Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "")
.toLowerCase()
: Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "");
/**
* Injects CSS into the document head.
* @memberOf utility
Expand Down Expand Up @@ -5351,6 +5363,7 @@ exports.requestInterval = requestInterval;
exports.resize = resize;
exports.rgbToHex = rgbToHex;
exports.ripple = ripple;
exports.round = round;
exports.runAsync = runAsync;
exports.sanitize = sanitize;
exports.saveBlob = saveBlob;
Expand Down
2 changes: 1 addition & 1 deletion docs/bijou.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/-_copyright.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/-_end.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/array.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/array.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/color.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/color.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/date.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/date.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/element.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/element.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/event.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/event.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/function.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/function.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/global.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/math.html

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions docs/docs/math.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/object.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/object.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/string.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/string.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/utility.html

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions docs/docs/utility.js.html

Large diffs are not rendered by default.

150 changes: 149 additions & 1 deletion js/_end.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,155 @@ export let prototype = (
* @author Explosion-Scratch, GrahamSH-LLK, Bijou.js contributors
*/

let _temp ={addDaysToDate, addEventListeners, addMinutesToDate, addStyles, animate, arrayDiff, arrayToCSV, attributes, averageBy, blendColors, browser, byteSize, camelCase, capitalize, clone, compStyle, composeFunction, contains, context, cookies, copy, count, create, createElement, curryFunction, dayName, debounce, deburr, diff, disableRightClick, dispatch, drag, each, ease, editDistance, elementContains, elementReady, elementSiblings, equals, escapeHTML, factorial, fastestFunction, flatten, flattenObj, forTemplateLiteral, formToObject, formatHTML, formatMilliseconds, formatNumber, fullScreen, gcd, getHTML, getImages, getJSON, hash, hashString, hexToRGB, htmlToImage, hub, imageToData, inPartialView, inView, injectCSS, inlineCSS, isAsync, isDateValid, isPrime, jaroDistance, jsonToCsv, juxt, lightOrDark, lightenColor, limitArgs, listen, loadScript, luhnCheck, mapObjectKeys, mapObjectValues, mapString, markdownToHTML, memoize, merge, mobileOrDesktop, nFlatten, notify, observeMutations, onOutsideClick, onScrollStop, parents, parseCookie, parseHTML, playSection, prefixCSS, preloadImage, previousPage, primesTo, prototype, querySelector, race, random, randomColor, range, regex, remove, removeComments, removeTags, renderElement, replaceBetween, replaceMultiple, replaceSelection, replaceText, requestInterval, resize, rgbToHex, ripple, runAsync, sanitize, saveBlob, scrambleString, seedRandom, serializeForm, shuffleArray, sleep, sortObj, sortTable, sortTableBy, soundex, speak, splice, spliceArrayBuffer, spread, syllables, tag, textNodes, throttle, tilt, timeFunction, titleCase, typeOf, unCamelCase, unescapeHTML, unionArrays, uniqueArray, urlQuery, uuid, waitUntil, widows};
let _temp = {
addDaysToDate,
addEventListeners,
addMinutesToDate,
addStyles,
animate,
arrayDiff,
arrayToCSV,
attributes,
averageBy,
blendColors,
browser,
byteSize,
camelCase,
capitalize,
clone,
compStyle,
composeFunction,
contains,
context,
cookies,
copy,
count,
create,
createElement,
curryFunction,
dayName,
debounce,
deburr,
diff,
disableRightClick,
dispatch,
drag,
each,
ease,
editDistance,
elementContains,
elementReady,
elementSiblings,
equals,
escapeHTML,
factorial,
fastestFunction,
flatten,
flattenObj,
forTemplateLiteral,
formToObject,
formatHTML,
formatMilliseconds,
formatNumber,
fullScreen,
gcd,
getHTML,
getImages,
getJSON,
hash,
hashString,
hexToRGB,
htmlToImage,
hub,
imageToData,
inPartialView,
inView,
injectCSS,
inlineCSS,
isAsync,
isDateValid,
isPrime,
jaroDistance,
jsonToCsv,
juxt,
lightOrDark,
lightenColor,
limitArgs,
listen,
loadScript,
luhnCheck,
mapObjectKeys,
mapObjectValues,
mapString,
markdownToHTML,
memoize,
merge,
mobileOrDesktop,
nFlatten,
notify,
observeMutations,
onOutsideClick,
onScrollStop,
parents,
parseCookie,
parseHTML,
playSection,
prefixCSS,
preloadImage,
previousPage,
primesTo,
prototype,
querySelector,
race,
random,
randomColor,
range,
regex,
remove,
removeComments,
removeTags,
renderElement,
replaceBetween,
replaceMultiple,
replaceSelection,
replaceText,
requestInterval,
resize,
rgbToHex,
ripple,
runAsync,
sanitize,
saveBlob,
scrambleString,
seedRandom,
serializeForm,
shuffleArray,
sleep,
sortObj,
sortTable,
sortTableBy,
soundex,
speak,
splice,
spliceArrayBuffer,
spread,
syllables,
tag,
textNodes,
throttle,
tilt,
timeFunction,
titleCase,
typeOf,
unCamelCase,
unescapeHTML,
unionArrays,
uniqueArray,
urlQuery,
uuid,
waitUntil,
widows,
};
_temp = sortObj(_temp);
// Imports and exports
export default _temp;
Expand Down
12 changes: 8 additions & 4 deletions js/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export let gcd = (...ary) => {
}
}
};
export let round = (number = req("number"), amount = 1) => Math.round(number / amount) * amount
export let round = (number = req("number"), amount = 1) =>
Math.round(number / amount) * amount;
/**
* Tests if two things are equal, like "thing === thing2" but it also works for dates and objects.
* @memberOf math
Expand All @@ -46,7 +47,8 @@ export let round = (number = req("number"), amount = 1) => Math.round(number / a
*/
export let equals = (a = req("any", "a"), b = req("any", "b")) => {
if (a === b) return true;
if (_$.typeOf(a) === "RegExp" && _$.typeOf(b) === "RegExp") return String(a) === String(b)
if (_$.typeOf(a) === "RegExp" && _$.typeOf(b) === "RegExp")
return String(a) === String(b);
if (a instanceof Date && b instanceof Date)
return a.getTime() === b.getTime();
if (!a || !b || (typeof a !== "object" && typeof b !== "object"))
Expand Down Expand Up @@ -223,8 +225,10 @@ export let random = (
if (min > max) {
[min, max] = [max, min];
}
var out = seed * (max - min + 1) + min
if (round) { out = Math.round(out)}
var out = seed * (max - min + 1) + min;
if (round) {
out = Math.round(out);
}
return out;
};
/**
Expand Down
11 changes: 10 additions & 1 deletion js/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,16 @@ export let race = (
* @param {Boolean} lowerCase Whether to return the string lowercased or not.
*/
export let typeOf = (e = req("any", "any"), lowerCase = true) =>
lowerCase ? Object.prototype.toString.call(e).split(" ")[1].replace(/]$/, "").toLowerCase() : Object.prototype.toString.call(e).split(" ")[1].replace(/]$/, "");
lowerCase
? Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "")
.toLowerCase()
: Object.prototype.toString
.call(e)
.split(" ")[1]
.replace(/]$/, "");
/**
* Injects CSS into the document head.
* @memberOf utility
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bijou.js",
"version": "8.1.0",
"version": "8.2.0",
"description": "Useful JavaScript snippets, in one simple library.",
"main": "bijou_node.js",
"jsdelivr": "bijou.js",
Expand Down

0 comments on commit d327e4c

Please sign in to comment.