deverything 0.0.1 → 0.1.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/README.md +37 -18
- package/dist/index.d.ts +19 -1
- package/dist/index.global.js +2 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2 -37
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DEVerything
|
|
2
2
|
|
|
3
|
-
## Everything you constantly need for dev
|
|
3
|
+
## Everything you constantly need for dev (and probably still copy-pasting)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The promise:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **1 package**: say goodbye to installing lodash, faker, this and that and the other one.
|
|
8
|
+
- **0 dependencies**: keep it simple and lightweight.
|
|
9
|
+
- **Pick the best**: the code is minimal and uses the best current practices and performance.
|
|
10
|
+
- **Typescript**: use it, support it and export it.
|
|
11
|
+
- **Intuitive**: favour always the most intuitive API, don't throw errors unless asked.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Contributions always welcome!
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
### Validators
|
|
12
16
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
17
|
+
- `isBrowser()`
|
|
18
|
+
- `isClient()`
|
|
19
|
+
- `isEmpty()`
|
|
20
|
+
- `isJsDate()`
|
|
21
|
+
- `isObject()`
|
|
22
|
+
- `isServer()`
|
|
23
|
+
- `isStringDate()`
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
### Helpers
|
|
20
26
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
- `parseDate(date: Date | string | number): Date`
|
|
28
|
+
|
|
29
|
+
### Random data generators
|
|
30
|
+
|
|
31
|
+
These functions are optimized for low entropy random data generation useful for Unit Testing, Storybook, Pass real validations, Reverse hacking, Penetration testing...
|
|
32
|
+
|
|
33
|
+
- `randomAddress(): { city: string, country: string, street: string, number: number, zip: string}`
|
|
34
|
+
- `randomArrayItem()`
|
|
35
|
+
- `randomBool()`
|
|
36
|
+
- `randomDate()`
|
|
37
|
+
- `randomFutureDate()`
|
|
38
|
+
- `randomPastDate()`
|
|
39
|
+
- `randomEmail()`
|
|
40
|
+
- `randomInt()`
|
|
41
|
+
- `randomName()`
|
|
42
|
+
- `randomFirstName()`
|
|
43
|
+
- `randomLastName()`
|
|
44
|
+
- `randomFullName()`
|
|
45
|
+
- `randomHandle()`
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,22 @@ declare const randomInt: (start?: number, end?: number) => number;
|
|
|
2
2
|
|
|
3
3
|
declare const isObject: (arg: any) => boolean;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
declare const isBrowser: () => boolean;
|
|
6
|
+
|
|
7
|
+
declare const isClient: () => boolean;
|
|
8
|
+
|
|
9
|
+
type Maybe<T> = T | null | undefined;
|
|
10
|
+
type MaybePromise<T> = Maybe<Promise<T>>;
|
|
11
|
+
type MaybePromiseOrValue<T> = MaybePromise<T> | T;
|
|
12
|
+
type MaybePromiseOrValueArray<T> = MaybePromiseOrValue<T>[];
|
|
13
|
+
type DateLike = Date | string | number;
|
|
14
|
+
|
|
15
|
+
declare const isEmpty: (value?: Maybe<any>) => boolean;
|
|
16
|
+
|
|
17
|
+
declare const isJsDate: (arg: any) => boolean;
|
|
18
|
+
|
|
19
|
+
declare const isServer: () => boolean;
|
|
20
|
+
|
|
21
|
+
declare const isStringDate: (arg: string) => boolean;
|
|
22
|
+
|
|
23
|
+
export { DateLike, Maybe, MaybePromise, MaybePromiseOrValue, MaybePromiseOrValueArray, isBrowser, isClient, isEmpty, isJsDate, isObject, isServer, isStringDate, randomInt };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(()=>{var i=(t=Number.MIN_VALUE,o=Number.MAX_VALUE)=>Math.floor(Math.random()*(o-t+1)+t);var p=t=>Object.prototype.toString.call(t)==="[object Object]";var e=()=>typeof window>"u";var r=()=>!e();var x=r;var d=t=>t==null||t==="";var n=t=>Object.prototype.toString.call(t)==="[object Date]"&&!isNaN(t);var M=t=>{let o=new Date(t);return n(o)};})();
|
|
2
|
+
//# sourceMappingURL=index.global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/random/randomInt.ts","../src/validators/isObject.ts","../src/validators/isServer.ts","../src/validators/isClient.ts","../src/validators/isBrowser.ts","../src/validators/isEmpty.ts","../src/validators/isJsDate.ts","../src/validators/isStringDate.ts"],"sourcesContent":["export const randomInt = (\n start: number = Number.MIN_VALUE,\n end: number = Number.MAX_VALUE\n): number => Math.floor(Math.random() * (end - start + 1) + start);\n","export const isObject = (arg: any): boolean =>\n Object.prototype.toString.call(arg) === \"[object Object]\";\n","export const isServer = () => typeof window === \"undefined\";\n","import { isServer } from \"./isServer\";\n\nexport const isClient = () => !isServer();\n","import { isClient } from \"./isClient\";\n\nexport const isBrowser = isClient;\n","import { Maybe } from \"../types\";\n\nexport const isEmpty = (value?: Maybe<any>) => {\n return value === undefined || value === null || value === \"\";\n};\n","export const isJsDate = (arg: any) =>\n Object.prototype.toString.call(arg) === \"[object Date]\" && !isNaN(arg);\n","import { isJsDate } from \"./isJsDate\";\n\nexport const isStringDate = (arg: string) => {\n const date = new Date(arg);\n return isJsDate(date);\n};\n"],"mappings":"mBAAO,IAAMA,EAAY,CACvBC,EAAgB,OAAO,UACvBC,EAAc,OAAO,YACV,KAAK,MAAM,KAAK,OAAO,GAAKA,EAAMD,EAAQ,GAAKA,CAAK,ECH1D,IAAME,EAAYC,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,kBCDnC,IAAMC,EAAW,IAAM,OAAO,OAAW,ICEzC,IAAMC,EAAW,IAAM,CAACC,EAAS,ECAjC,IAAMC,EAAYC,ECAlB,IAAMC,EAAWC,GACQA,GAAU,MAAQA,IAAU,GCHrD,IAAMC,EAAYC,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,iBAAmB,CAAC,MAAMA,CAAG,ECChE,IAAMC,EAAgBC,GAAgB,CAC3C,IAAMC,EAAO,IAAI,KAAKD,CAAG,EACzB,OAAOE,EAASD,CAAI,CACtB","names":["randomInt","start","end","isObject","arg","isServer","isClient","isServer","isBrowser","isClient","isEmpty","value","isJsDate","arg","isStringDate","arg","date","isJsDate"]}
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
isObject: () => isObject,
|
|
24
|
-
randomInt: () => randomInt
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
|
|
28
|
-
// src/random/randomInt.ts
|
|
29
|
-
var randomInt = (start = Number.MIN_VALUE, end = Number.MAX_VALUE) => Math.floor(Math.random() * (end - start + 1) + start);
|
|
30
|
-
|
|
31
|
-
// src/validators/isObject.ts
|
|
32
|
-
var isObject = (arg) => Object.prototype.toString.call(arg) === "[object Object]";
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
isObject,
|
|
36
|
-
randomInt
|
|
37
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var i=(t=Number.MIN_VALUE,o=Number.MAX_VALUE)=>Math.floor(Math.random()*(o-t+1)+t);var p=t=>Object.prototype.toString.call(t)==="[object Object]";var e=()=>typeof window>"u";var r=()=>!e();var x=r;var d=t=>t==null||t==="";var n=t=>Object.prototype.toString.call(t)==="[object Date]"&&!isNaN(t);var M=t=>{let o=new Date(t);return n(o)};exports.isBrowser = x; exports.isClient = r; exports.isEmpty = d; exports.isJsDate = n; exports.isObject = p; exports.isServer = e; exports.isStringDate = M; exports.randomInt = i;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/random/randomInt.ts","../src/validators/isObject.ts","../src/validators/isServer.ts","../src/validators/isClient.ts","../src/validators/isBrowser.ts","../src/validators/isEmpty.ts","../src/validators/isJsDate.ts","../src/validators/isStringDate.ts"],"names":["randomInt","start","end","isObject","arg","isServer","isClient","isBrowser","isEmpty","value","isJsDate","isStringDate","date"],"mappings":"AAAO,IAAMA,EAAY,CACvBC,EAAgB,OAAO,UACvBC,EAAc,OAAO,YACV,KAAK,MAAM,KAAK,OAAO,GAAKA,EAAMD,EAAQ,GAAKA,CAAK,ECH1D,IAAME,EAAYC,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,kBCDnC,IAAMC,EAAW,IAAM,OAAO,OAAW,ICEzC,IAAMC,EAAW,IAAM,CAACD,EAAS,ECAjC,IAAME,EAAYD,ECAlB,IAAME,EAAWC,GACQA,GAAU,MAAQA,IAAU,GCHrD,IAAMC,EAAYN,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,iBAAmB,CAAC,MAAMA,CAAG,ECChE,IAAMO,EAAgBP,GAAgB,CAC3C,IAAMQ,EAAO,IAAI,KAAKR,CAAG,EACzB,OAAOM,EAASE,CAAI,CACtB","sourcesContent":["export const randomInt = (\n start: number = Number.MIN_VALUE,\n end: number = Number.MAX_VALUE\n): number => Math.floor(Math.random() * (end - start + 1) + start);\n","export const isObject = (arg: any): boolean =>\n Object.prototype.toString.call(arg) === \"[object Object]\";\n","export const isServer = () => typeof window === \"undefined\";\n","import { isServer } from \"./isServer\";\n\nexport const isClient = () => !isServer();\n","import { isClient } from \"./isClient\";\n\nexport const isBrowser = isClient;\n","import { Maybe } from \"../types\";\n\nexport const isEmpty = (value?: Maybe<any>) => {\n return value === undefined || value === null || value === \"\";\n};\n","export const isJsDate = (arg: any) =>\n Object.prototype.toString.call(arg) === \"[object Date]\" && !isNaN(arg);\n","import { isJsDate } from \"./isJsDate\";\n\nexport const isStringDate = (arg: string) => {\n const date = new Date(arg);\n return isJsDate(date);\n};\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=(t=Number.MIN_VALUE,o=Number.MAX_VALUE)=>Math.floor(Math.random()*(o-t+1)+t);var p=t=>Object.prototype.toString.call(t)==="[object Object]";var e=()=>typeof window>"u";var r=()=>!e();var x=r;var d=t=>t==null||t==="";var n=t=>Object.prototype.toString.call(t)==="[object Date]"&&!isNaN(t);var M=t=>{let o=new Date(t);return n(o)};export{x as isBrowser,r as isClient,d as isEmpty,n as isJsDate,p as isObject,e as isServer,M as isStringDate,i as randomInt};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/random/randomInt.ts","../src/validators/isObject.ts","../src/validators/isServer.ts","../src/validators/isClient.ts","../src/validators/isBrowser.ts","../src/validators/isEmpty.ts","../src/validators/isJsDate.ts","../src/validators/isStringDate.ts"],"sourcesContent":["export const randomInt = (\n start: number = Number.MIN_VALUE,\n end: number = Number.MAX_VALUE\n): number => Math.floor(Math.random() * (end - start + 1) + start);\n","export const isObject = (arg: any): boolean =>\n Object.prototype.toString.call(arg) === \"[object Object]\";\n","export const isServer = () => typeof window === \"undefined\";\n","import { isServer } from \"./isServer\";\n\nexport const isClient = () => !isServer();\n","import { isClient } from \"./isClient\";\n\nexport const isBrowser = isClient;\n","import { Maybe } from \"../types\";\n\nexport const isEmpty = (value?: Maybe<any>) => {\n return value === undefined || value === null || value === \"\";\n};\n","export const isJsDate = (arg: any) =>\n Object.prototype.toString.call(arg) === \"[object Date]\" && !isNaN(arg);\n","import { isJsDate } from \"./isJsDate\";\n\nexport const isStringDate = (arg: string) => {\n const date = new Date(arg);\n return isJsDate(date);\n};\n"],"mappings":"AAAO,IAAMA,EAAY,CACvBC,EAAgB,OAAO,UACvBC,EAAc,OAAO,YACV,KAAK,MAAM,KAAK,OAAO,GAAKA,EAAMD,EAAQ,GAAKA,CAAK,ECH1D,IAAME,EAAYC,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,kBCDnC,IAAMC,EAAW,IAAM,OAAO,OAAW,ICEzC,IAAMC,EAAW,IAAM,CAACC,EAAS,ECAjC,IAAMC,EAAYC,ECAlB,IAAMC,EAAWC,GACQA,GAAU,MAAQA,IAAU,GCHrD,IAAMC,EAAYC,GACvB,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,iBAAmB,CAAC,MAAMA,CAAG,ECChE,IAAMC,EAAgBC,GAAgB,CAC3C,IAAMC,EAAO,IAAI,KAAKD,CAAG,EACzB,OAAOE,EAASD,CAAI,CACtB","names":["randomInt","start","end","isObject","arg","isServer","isClient","isServer","isBrowser","isClient","isEmpty","value","isJsDate","arg","isStringDate","arg","date","isJsDate"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deverything",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Everything you need for Dev",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"typescript": "^4.9.5"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "tsup
|
|
45
|
-
"dev": "tsup
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"dev": "tsup --watch",
|
|
46
46
|
"lint": "TIMING=1 eslint src --fix",
|
|
47
47
|
"clean": "rm -rf node_modules && rm -rf dist",
|
|
48
|
-
"prepublish": "pnpm build",
|
|
48
|
+
"prepublish": "pnpm test && pnpm build",
|
|
49
49
|
"test": "jest"
|
|
50
50
|
}
|
|
51
51
|
}
|