e22m4u 1 неделя назад
Родитель
Сommit
6f4fc50dd0

+ 2 - 2
dist/cjs/index.cjs

@@ -65,7 +65,7 @@ var _Debuggable = class _Debuggable {
   /**
    * Debug.
    *
-   * @type {Function}
+   * @type {*}
    */
   debug;
   /**
@@ -109,7 +109,7 @@ var _Debuggable = class _Debuggable {
 };
 __name(_Debuggable, "Debuggable");
 /**
- * Instantiation message;
+ * Instantiation message.
  *
  * @type {string}
  */

+ 1 - 0
package.json

@@ -46,6 +46,7 @@
     "@commitlint/config-conventional": "~20.0.0",
     "@e22m4u/js-spy": "~0.2.0",
     "@eslint/js": "~9.39.1",
+    "@types/mocha": "^10.0.10",
     "c8": "~10.1.3",
     "chai": "~6.2.1",
     "esbuild": "~0.27.0",

+ 5 - 0
src/create-debugger.d.ts

@@ -1,3 +1,8 @@
+/**
+ * Стандартное количество пробелов в одном шаге смещения.
+ */
+export const DEFAULT_OFFSET_STEP_SPACES: number;
+
 /**
  * Объект конфигурации, который хранит все настройки
  * для конкретного экземпляра отладчика.

+ 1 - 1
src/create-debugger.js

@@ -108,7 +108,7 @@ function matchPattern(pattern, input) {
  * Create debugger.
  *
  * @param {string} namespaceOrOptions
- * @param {string} namespaceSegments
+ * @param {string[]} namespaceSegments
  * @returns {Function}
  */
 export function createDebugger(

+ 13 - 0
src/create-debugger.spec.js

@@ -20,6 +20,12 @@ describe('createDebugger', function () {
     originalLocalStorage = global.localStorage;
     global.localStorage = {
       _store: {},
+      get length() {
+        return Object.keys(this._store).length;
+      },
+      key(num) {
+        return Object.keys(this._store)[num] || null;
+      },
       getItem(key) {
         return this._store[key] || null;
       },
@@ -262,6 +268,7 @@ describe('createDebugger', function () {
     });
 
     it('should throw error if createDebugger is called with invalid subsequent segment type', function () {
+      // @ts-ignore
       expect(() => createDebugger('app', 'valid', 123)).to.throw(
         /Namespace segment must be a non-empty String/,
       );
@@ -278,6 +285,7 @@ describe('createDebugger', function () {
 
     it('should throw error if withNs is called with non-string', function () {
       const debug = createDebugger('app');
+      // @ts-ignore
       expect(() => debug.withNs(123)).to.throw(
         /Debugger namespace must be a non-empty String/,
       );
@@ -467,6 +475,7 @@ describe('createDebugger', function () {
       expect(() => debug.withHash(0)).to.throw(/must be a positive Number/);
       expect(() => debug.withHash(-1)).to.throw(/must be a positive Number/);
       expect(() => debug.withHash(null)).to.throw(/must be a positive Number/);
+      // @ts-ignore
       expect(() => debug.withHash('abc')).to.throw(/must be a positive Number/);
     });
 
@@ -511,6 +520,7 @@ describe('createDebugger', function () {
       expect(() => debug.withOffset(null)).to.throw(
         /must be a positive Number/,
       );
+      // @ts-ignore
       expect(() => debug.withOffset('abc')).to.throw(
         /must be a positive Number/,
       );
@@ -554,12 +564,15 @@ describe('createDebugger', function () {
 
   describe('creation error', function () {
     it('should throw error if createDebugger is called with invalid type', function () {
+      // @ts-ignore
       expect(() => createDebugger(123)).to.throw(
         /must be a String or an Object/,
       );
+      // @ts-ignore
       expect(() => createDebugger(true)).to.throw(
         /must be a String or an Object/,
       );
+      // @ts-ignore
       expect(() => createDebugger([])).to.throw(
         /must be a String or an Object/,
       );

+ 5 - 0
src/debuggable.d.ts

@@ -14,6 +14,11 @@ export type DebuggableOptions = {
  * Debuggable.
  */
 export class Debuggable {
+  /**
+   * Instantiation message.
+   */
+  static INSTANTIATION_MESSAGE: string;
+
   /**
    * Debug.
    */

+ 2 - 2
src/debuggable.js

@@ -14,7 +14,7 @@ import {createDebugger} from '@e22m4u/js-debug';
  */
 export class Debuggable {
   /**
-   * Instantiation message;
+   * Instantiation message.
    *
    * @type {string}
    */
@@ -23,7 +23,7 @@ export class Debuggable {
   /**
    * Debug.
    *
-   * @type {Function}
+   * @type {*}
    */
   debug;
 

+ 1 - 1
src/utils/escape-regexp.js

@@ -1,7 +1,7 @@
 /**
  * Экранирует специальные символы в строке для использования в регулярном выражении.
  *
- * @param {string} str
+ * @param {string|number} str
  * @returns {string}
  */
 export function escapeRegexp(str) {

+ 8 - 3
tsconfig.json

@@ -1,9 +1,14 @@
 {
   "compilerOptions": {
-    "rootDir": "src",
     "noEmit": true,
     "target": "es2022",
     "module": "NodeNext",
-    "moduleResolution": "NodeNext"
-  }
+    "moduleResolution": "NodeNext",
+    "allowJs": true,
+    "checkJs": true
+  },
+  "include": [
+    "./src/**/*.ts",
+    "./src/**/*.js"
+  ]
 }