@jamesrock/rockjs 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12,11 +12,14 @@ export const pluckLast = (a) => a.splice(a.length-1, 1)[0];
|
|
|
12
12
|
export const getRandom = (a) => a[randomIndex(a)];
|
|
13
13
|
export const isLandscape = () => window.matchMedia('(orientation: landscape)').matches;
|
|
14
14
|
export const isTiny = () => !window.matchMedia('(min-width: 450px)').matches;
|
|
15
|
+
export const isDarkMode = () => window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
15
16
|
export const makeEven = (value) => value % 2 === 1 ? value - 1 : value;
|
|
16
17
|
export const limit = (value, max) => value > max ? max : value;
|
|
17
18
|
export const formatTime = (t) => `${pad(formatMinutes(t))}:${pad(formatSeconds(t))}`;
|
|
18
19
|
export const formatNumber = (n) => formatter.format(n);
|
|
19
20
|
export const formatCurrency = (n) => currencyFormatter.format(n);
|
|
21
|
+
export const getDateString = () => new Date().toLocaleDateString('en-GB', { year: 'numeric', month: 'numeric', day: 'numeric'});
|
|
22
|
+
export const isValidKey = (key, options) => (options.includes(key));
|
|
20
23
|
export const shuffle = (array) => {
|
|
21
24
|
for(let i = array.length - 1; i > 0; i--) {
|
|
22
25
|
const j = Math.floor(Math.random() * (i + 1));
|