@yaasl/utils 0.7.0-alpha.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.
@@ -0,0 +1,3 @@
1
+ export * from "./log";
2
+ export * from "./utilTypes";
3
+ export * from "./mockConsole";
@@ -0,0 +1,5 @@
1
+ export declare const consoleMessage: (text: string) => string;
2
+ export declare const log: {
3
+ warn: (text: string, value?: unknown) => void;
4
+ error: (text: string, value?: unknown) => void;
5
+ };
@@ -0,0 +1,6 @@
1
+ /// <reference types="jest" />
2
+ export declare const mockConsole: () => {
3
+ error: jest.Mock<any, any, any>;
4
+ warn: jest.Mock<any, any, any>;
5
+ resetConsole: () => Console;
6
+ };
@@ -0,0 +1,5 @@
1
+ export type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
4
+ export type Dispatch<T> = (value: T) => void;
5
+ export type SetStateAction<State> = State | ((prevState: State) => State);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./log"), exports);
18
+ __exportStar(require("./utilTypes"), exports);
19
+ __exportStar(require("./mockConsole"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = exports.consoleMessage = void 0;
4
+ const consoleMessage = (text) => `${text} (yaasl)`;
5
+ exports.consoleMessage = consoleMessage;
6
+ const logger = (type, text, value) => console[type]((0, exports.consoleMessage)(text), ...(!value ? [] : ["\n\n", value]));
7
+ exports.log = {
8
+ warn: (text, value) => logger("warn", text, value),
9
+ error: (text, value) => logger("error", text, value),
10
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockConsole = void 0;
4
+ const mockConsole = () => {
5
+ const oldConsole = global.console;
6
+ const error = jest.fn();
7
+ const warn = jest.fn();
8
+ global.console = Object.assign(Object.assign({}, global.console), { error, warn });
9
+ return { error, warn, resetConsole: () => (global.console = oldConsole) };
10
+ };
11
+ exports.mockConsole = mockConsole;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from "./log";
2
+ export * from "./utilTypes";
3
+ export * from "./mockConsole";
@@ -0,0 +1,6 @@
1
+ export const consoleMessage = (text) => `${text} (yaasl)`;
2
+ const logger = (type, text, value) => console[type](consoleMessage(text), ...(!value ? [] : ["\n\n", value]));
3
+ export const log = {
4
+ warn: (text, value) => logger("warn", text, value),
5
+ error: (text, value) => logger("error", text, value),
6
+ };
@@ -0,0 +1,7 @@
1
+ export const mockConsole = () => {
2
+ const oldConsole = global.console;
3
+ const error = jest.fn();
4
+ const warn = jest.fn();
5
+ global.console = { ...global.console, error, warn };
6
+ return { error, warn, resetConsole: () => (global.console = oldConsole) };
7
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@yaasl/utils",
3
+ "version": "0.7.0-alpha.0",
4
+ "description": "Utilities for @yaasl packages",
5
+ "author": "PrettyCoffee",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/PrettyCoffee/yaasl#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/PrettyCoffee/yaasl.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/PrettyCoffee/yaasl/issues"
14
+ },
15
+ "main": "./dist/cjs/index.js",
16
+ "types": "./dist/@types/index.d.ts",
17
+ "exports": {
18
+ "types": "./dist/@types/index.d.ts",
19
+ "import": "./dist/mjs/index.js",
20
+ "require": "./dist/cjs/index.js"
21
+ },
22
+ "scripts": {
23
+ "build": "run-s clean compile",
24
+ "clean": "rimraf ./dist",
25
+ "compile": "run-p compile:mjs compile:cjs compile:types",
26
+ "compile:mjs": "tsc -p ./tsconfig.node.json --outDir ./dist/mjs -m es2020 -t es2020",
27
+ "compile:cjs": "tsc -p ./tsconfig.node.json --outDir ./dist/cjs -m commonjs -t es2015",
28
+ "compile:types": "tsc -p ./tsconfig.node.json --outDir ./dist/@types --declaration --emitDeclarationOnly",
29
+ "test": "jest --testMatch ./**/*.test.* --passWithNoTests",
30
+ "test:watch": "npm run test -- --watchAll",
31
+ "lint": "eslint ./src",
32
+ "lint:fix": "eslint ./src --fix",
33
+ "validate": "run-s lint test build"
34
+ },
35
+ "jest": {
36
+ "preset": "ts-jest",
37
+ "testEnvironment": "jsdom"
38
+ },
39
+ "eslintConfig": {
40
+ "extends": [
41
+ "../../.eslintrc"
42
+ ]
43
+ },
44
+ "lint-staged": {
45
+ "*.{ts,tsx}": [
46
+ "npm run lint:fix"
47
+ ]
48
+ }
49
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["./src"],
4
+ "exclude": ["./**/*.test.ts"],
5
+ "compilerOptions": {
6
+ "declaration": false,
7
+ "noEmit": false,
8
+ }
9
+ }