@inyur/console-warn-once 1.0.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/.eslintrc.cjs +24 -0
- package/.gitlab-ci.yml +11 -0
- package/.prettierrc +12 -0
- package/.renovaterc.json5 +6 -0
- package/README.md +17 -0
- package/dist/cjs/console-warn-once.d.ts +3 -0
- package/dist/cjs/console-warn-once.js +14 -0
- package/dist/cjs/console-warn-once.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/mjs/console-warn-once.d.ts +3 -0
- package/dist/mjs/console-warn-once.js +12 -0
- package/dist/mjs/console-warn-once.js.map +1 -0
- package/dist/mjs/index.d.ts +2 -0
- package/dist/mjs/index.js +3 -0
- package/dist/mjs/index.js.map +1 -0
- package/dist/mjs/package.json +3 -0
- package/dist/types/console-warn-once.d.ts +3 -0
- package/dist/types/index.d.ts +2 -0
- package/fixup.sh +11 -0
- package/package.json +39 -0
- package/src/console-warn-once.ts +17 -0
- package/src/index.ts +2 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.json +28 -0
- package/tsconfig.mjs.json +8 -0
- package/tsconfig.types.json +8 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
tsconfigRootDir: __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
},
|
|
17
|
+
ignorePatterns: ['.eslintrc.js'],
|
|
18
|
+
rules: {
|
|
19
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
20
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
22
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
23
|
+
},
|
|
24
|
+
};
|
package/.gitlab-ci.yml
ADDED
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# console-warn-once
|
|
2
|
+
|
|
3
|
+
## Motivation
|
|
4
|
+
Sometime we need warn some events, but without pollution of console.
|
|
5
|
+
npm has `console-once` package, but it only es6, and in nuxt and nest js it dont work, as this frameworks in server side works in es5.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
```shell
|
|
9
|
+
npm i -S @inyur/console-warn-once
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
import consoleWarnOnce from '@inyur/console-warn-once';
|
|
14
|
+
|
|
15
|
+
consoleWarnOnce('Some message');
|
|
16
|
+
// eqivalent console.warn('Some message'); // but only once;
|
|
17
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consoleWarnOnce = consoleWarnOnce;
|
|
4
|
+
const ref = {
|
|
5
|
+
showed: [],
|
|
6
|
+
};
|
|
7
|
+
function consoleWarnOnce(msg) {
|
|
8
|
+
if (ref.showed.includes(msg))
|
|
9
|
+
return;
|
|
10
|
+
ref.showed.push(msg);
|
|
11
|
+
console.warn(msg);
|
|
12
|
+
}
|
|
13
|
+
exports.default = consoleWarnOnce;
|
|
14
|
+
//# sourceMappingURL=console-warn-once.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-warn-once.js","sourceRoot":"","sources":["../../src/console-warn-once.ts"],"names":[],"mappings":";;AAcS,0CAAe;AAVxB,MAAM,GAAG,GAAyB;IAChC,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO;IACrC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;AAID,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.default = void 0;
|
|
21
|
+
var console_warn_once_1 = require("./console-warn-once");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(console_warn_once_1).default; } });
|
|
23
|
+
__exportStar(require("./console-warn-once"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,yDAA8C;AAArC,6HAAA,OAAO,OAAA;AAChB,sDAAoC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const ref = {
|
|
2
|
+
showed: [],
|
|
3
|
+
};
|
|
4
|
+
function consoleWarnOnce(msg) {
|
|
5
|
+
if (ref.showed.includes(msg))
|
|
6
|
+
return;
|
|
7
|
+
ref.showed.push(msg);
|
|
8
|
+
console.warn(msg);
|
|
9
|
+
}
|
|
10
|
+
export { consoleWarnOnce };
|
|
11
|
+
export default consoleWarnOnce;
|
|
12
|
+
//# sourceMappingURL=console-warn-once.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-warn-once.js","sourceRoot":"","sources":["../../src/console-warn-once.ts"],"names":[],"mappings":"AAIA,MAAM,GAAG,GAAyB;IAChC,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO;IACrC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,cAAc,qBAAqB,CAAC"}
|
package/fixup.sh
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inyur/console-warn-once",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/mjs/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/mjs/index.js",
|
|
13
|
+
"require": "./dist/cjs/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -fr dist/* && tsc -p tsconfig.mjs.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./fixup.sh",
|
|
18
|
+
"build:watch": "nodemon --watch src -e ts --exec 'npm run build'"
|
|
19
|
+
},
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/lodash": "^4.17.16",
|
|
24
|
+
"@types/node": "^20.17.46",
|
|
25
|
+
"@types/web": "^0.0.233",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
27
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
28
|
+
"eslint": "^8.57.1",
|
|
29
|
+
"eslint-config-prettier": "^9.1.0",
|
|
30
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
31
|
+
"nestjs-i18n": "^10.5.1",
|
|
32
|
+
"nodemon": "^3.1.10",
|
|
33
|
+
"prettier": "^3.5.3",
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const console: {
|
|
2
|
+
warn(message?: any, ...optionalParams: any[]): void;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const ref: { showed: string[] } = {
|
|
6
|
+
showed: [],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function consoleWarnOnce(msg: string): void {
|
|
10
|
+
if (ref.showed.includes(msg)) return;
|
|
11
|
+
ref.showed.push(msg);
|
|
12
|
+
console.warn(msg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { consoleWarnOnce };
|
|
16
|
+
|
|
17
|
+
export default consoleWarnOnce;
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"baseUrl": "src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"inlineSourceMap": false,
|
|
10
|
+
"lib": ["esnext"],
|
|
11
|
+
"listEmittedFiles": false,
|
|
12
|
+
"listFiles": false,
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"pretty": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"rootDir": "src",
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strict": true,
|
|
20
|
+
"traceResolution": false,
|
|
21
|
+
"strictPropertyInitialization": false,
|
|
22
|
+
"emitDecoratorMetadata": true,
|
|
23
|
+
"experimentalDecorators": true
|
|
24
|
+
},
|
|
25
|
+
"compileOnSave": false,
|
|
26
|
+
"exclude": ["node_modules", "dist"],
|
|
27
|
+
"include": ["src"]
|
|
28
|
+
}
|