@e22m4u/ts-rest-router 0.6.0 → 0.6.2

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.
@@ -16,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
21
 
21
22
  // dist/esm/index.js
@@ -41,8 +42,6 @@ __export(index_exports, {
41
42
  RestRouter: () => RestRouter,
42
43
  afterAction: () => afterAction,
43
44
  beforeAction: () => beforeAction,
44
- capitalize: () => capitalize,
45
- createError: () => createError,
46
45
  deleteAction: () => deleteAction,
47
46
  getAction: () => getAction,
48
47
  httpRequest: () => httpRequest,
@@ -65,77 +64,41 @@ __export(index_exports, {
65
64
  requestQuery: () => requestQuery,
66
65
  responseBody: () => responseBody,
67
66
  restAction: () => restAction,
68
- restController: () => restController,
69
- toCamelCase: () => toCamelCase
67
+ restController: () => restController
70
68
  });
71
69
  module.exports = __toCommonJS(index_exports);
72
-
73
- // dist/esm/utils/capitalize.js
74
- function capitalize(input) {
75
- return input.charAt(0).toUpperCase() + input.slice(1);
76
- }
77
- __name(capitalize, "capitalize");
78
-
79
- // dist/esm/utils/create-error.js
80
- var import_js_format = require("@e22m4u/js-format");
81
- function createError(errorCtor, message, ...args) {
82
- const interpolatedMessage = (0, import_js_format.format)(message, ...args);
83
- return new errorCtor(interpolatedMessage);
84
- }
85
- __name(createError, "createError");
86
-
87
- // dist/esm/utils/to-camel-case.js
88
- function toCamelCase(input) {
89
- return input.replace(/(^\w|[A-Z]|\b\w)/g, (c) => c.toUpperCase()).replace(/\W+/g, "").replace(/(^\w)/g, (c) => c.toLowerCase());
90
- }
91
- __name(toCamelCase, "toCamelCase");
70
+ __reExport(index_exports, require("@e22m4u/js-trie-router"), module.exports);
92
71
 
93
72
  // dist/esm/rest-router.js
94
73
  var import_js_trie_router3 = require("@e22m4u/js-trie-router");
95
74
 
96
75
  // dist/esm/debuggable-service.js
97
76
  var import_js_service = require("@e22m4u/js-service");
98
- var import_js_debug = require("@e22m4u/js-debug");
99
- var _DebuggableService = class _DebuggableService extends import_js_service.Service {
100
- /**
101
- * Debug.
102
- */
103
- debug;
104
- /**
105
- * Возвращает функцию-отладчик с сегментом пространства имен
106
- * указанного в параметре метода.
107
- *
108
- * @param method
109
- * @protected
110
- */
111
- getDebuggerFor(method) {
112
- return this.debug.withHash().withNs(method.name);
113
- }
77
+ var _DebuggableService = class _DebuggableService extends import_js_service.DebuggableService {
114
78
  /**
115
79
  * Constructor.
116
80
  *
117
81
  * @param container
118
82
  */
119
83
  constructor(container) {
120
- super(container);
121
- const serviceName = toCamelCase(this.constructor.name);
122
- this.debug = (0, import_js_debug.createDebugger)("tsRestRouter", serviceName).withoutEnvNs();
123
- const debug = this.debug.withNs("constructor").withHash();
124
- debug("Service created.");
84
+ super(container, {
85
+ namespace: "tsRestRouter",
86
+ noEnvironmentNamespace: true
87
+ });
125
88
  }
126
89
  };
127
90
  __name(_DebuggableService, "DebuggableService");
128
91
  var DebuggableService = _DebuggableService;
129
92
 
130
93
  // dist/esm/controller-registry.js
131
- var import_js_format3 = require("@e22m4u/js-format");
94
+ var import_js_format2 = require("@e22m4u/js-format");
132
95
  var import_js_trie_router2 = require("@e22m4u/js-trie-router");
133
96
  var import_ts_data_schema2 = require("@e22m4u/ts-data-schema");
134
97
  var import_ts_data_schema3 = require("@e22m4u/ts-data-schema");
135
98
 
136
99
  // dist/esm/errors/not-a-controller-error.js
137
- var import_js_format2 = require("@e22m4u/js-format");
138
- var _NotAControllerError = class _NotAControllerError extends import_js_format2.Errorf {
100
+ var import_js_format = require("@e22m4u/js-format");
101
+ var _NotAControllerError = class _NotAControllerError extends import_js_format.Errorf {
139
102
  /**
140
103
  * Constructor.
141
104
  *
@@ -631,7 +594,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
631
594
  addController(ctor, options) {
632
595
  const debug = this.getDebuggerFor(this.addController);
633
596
  if (this.hasController(ctor))
634
- throw new import_js_format3.Errorf("The controller %v is already registered.", ctor.name);
597
+ throw new import_js_format2.Errorf("The controller %v is already registered.", ctor.name);
635
598
  const controllerMd = RestControllerReflector.getMetadata(ctor);
636
599
  if (!controllerMd)
637
600
  throw new NotAControllerError(ctor);
@@ -718,7 +681,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
718
681
  debug("Metadata target is %s.", ctor.name);
719
682
  const md = RestControllerReflector.getMetadata(ctor);
720
683
  if (!md)
721
- throw new import_js_format3.Errorf("Controller %v has no metadata.", ctor);
684
+ throw new import_js_format2.Errorf("Controller %v has no metadata.", ctor);
722
685
  const res = md.path || "";
723
686
  debug("Controller path prefix is %v.", res);
724
687
  return md.path || "";
@@ -822,7 +785,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
822
785
  debug("Target is %s.", ctor.name);
823
786
  const md = RestControllerReflector.getMetadata(ctor);
824
787
  if (!md)
825
- throw new import_js_format3.Errorf("Controller %v has no metadata.", ctor);
788
+ throw new import_js_format2.Errorf("Controller %v has no metadata.", ctor);
826
789
  let res = [];
827
790
  if (md.before)
828
791
  res = Array.isArray(md.before) ? md.before : [md.before];
@@ -839,7 +802,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
839
802
  debug("Getting post-handlers from @restController metadata.");
840
803
  const md = RestControllerReflector.getMetadata(ctor);
841
804
  if (!md)
842
- throw new import_js_format3.Errorf("Controller %v has no metadata.", ctor);
805
+ throw new import_js_format2.Errorf("Controller %v has no metadata.", ctor);
843
806
  let res = [];
844
807
  if (md.after)
845
808
  res = Array.isArray(md.after) ? md.after : [md.after];
@@ -858,7 +821,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
858
821
  const actionsMd = RestActionReflector.getMetadata(ctor);
859
822
  const actionMd = actionsMd.get(actionName);
860
823
  if (!actionMd)
861
- throw new import_js_format3.Errorf("Action %s.%s has no metadata.", ctor.name, actionName);
824
+ throw new import_js_format2.Errorf("Action %s.%s has no metadata.", ctor.name, actionName);
862
825
  let res = [];
863
826
  if (actionMd.before)
864
827
  res = Array.isArray(actionMd.before) ? actionMd.before : [actionMd.before];
@@ -877,7 +840,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
877
840
  const actionsMd = RestActionReflector.getMetadata(ctor);
878
841
  const actionMd = actionsMd.get(actionName);
879
842
  if (!actionMd)
880
- throw new import_js_format3.Errorf("Action %s.%s has no metadata.", ctor.name, actionName);
843
+ throw new import_js_format2.Errorf("Action %s.%s has no metadata.", ctor.name, actionName);
881
844
  let res = [];
882
845
  if (actionMd.after)
883
846
  res = Array.isArray(actionMd.after) ? actionMd.after : [actionMd.after];
@@ -975,7 +938,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
975
938
  }
976
939
  });
977
940
  if (requestContext2.container.has(controllerCtor))
978
- throw new import_js_format3.Errorf("The controller %v is already registered, which breaks controller isolation per request.", controllerCtor.name);
941
+ throw new import_js_format2.Errorf("The controller %v is already registered, which breaks controller isolation per request.", controllerCtor.name);
979
942
  const controller = requestContext2.container.get(controllerCtor);
980
943
  return controller[actionName](...args);
981
944
  };
@@ -1002,6 +965,16 @@ var _RestRouter = class _RestRouter extends DebuggableService {
1002
965
  this.getService(ControllerRegistry).addController(ctor, options);
1003
966
  return this;
1004
967
  }
968
+ /**
969
+ * Add hook.
970
+ *
971
+ * @param type
972
+ * @param hook
973
+ */
974
+ addHook(type, hook) {
975
+ this.getService(import_js_trie_router3.TrieRouter).addHook(type, hook);
976
+ return this;
977
+ }
1005
978
  };
1006
979
  __name(_RestRouter, "RestRouter");
1007
980
  var RestRouter = _RestRouter;
@@ -1027,8 +1000,6 @@ var RestRouter = _RestRouter;
1027
1000
  RestRouter,
1028
1001
  afterAction,
1029
1002
  beforeAction,
1030
- capitalize,
1031
- createError,
1032
1003
  deleteAction,
1033
1004
  getAction,
1034
1005
  httpRequest,
@@ -1052,5 +1023,5 @@ var RestRouter = _RestRouter;
1052
1023
  responseBody,
1053
1024
  restAction,
1054
1025
  restController,
1055
- toCamelCase
1026
+ ...require("@e22m4u/js-trie-router")
1056
1027
  });
@@ -1,23 +1,9 @@
1
- import { Callable } from './types.js';
2
- import { Debugger } from '@e22m4u/js-debug';
3
- import { Service } from '@e22m4u/js-service';
4
1
  import { ServiceContainer } from '@e22m4u/js-service';
2
+ import { DebuggableService as BaseDebuggableService } from '@e22m4u/js-service';
5
3
  /**
6
- * Service.
4
+ * Base debuggable service.
7
5
  */
8
- export declare class DebuggableService extends Service {
9
- /**
10
- * Debug.
11
- */
12
- debug: Debugger;
13
- /**
14
- * Возвращает функцию-отладчик с сегментом пространства имен
15
- * указанного в параметре метода.
16
- *
17
- * @param method
18
- * @protected
19
- */
20
- protected getDebuggerFor(method: Callable): Debugger;
6
+ export declare class DebuggableService extends BaseDebuggableService {
21
7
  /**
22
8
  * Constructor.
23
9
  *
@@ -1,34 +1,17 @@
1
- import { Service } from '@e22m4u/js-service';
2
- import { toCamelCase } from './utils/index.js';
3
- import { createDebugger } from '@e22m4u/js-debug';
1
+ import { DebuggableService as BaseDebuggableService } from '@e22m4u/js-service';
4
2
  /**
5
- * Service.
3
+ * Base debuggable service.
6
4
  */
7
- export class DebuggableService extends Service {
8
- /**
9
- * Debug.
10
- */
11
- debug;
12
- /**
13
- * Возвращает функцию-отладчик с сегментом пространства имен
14
- * указанного в параметре метода.
15
- *
16
- * @param method
17
- * @protected
18
- */
19
- getDebuggerFor(method) {
20
- return this.debug.withHash().withNs(method.name);
21
- }
5
+ export class DebuggableService extends BaseDebuggableService {
22
6
  /**
23
7
  * Constructor.
24
8
  *
25
9
  * @param container
26
10
  */
27
11
  constructor(container) {
28
- super(container);
29
- const serviceName = toCamelCase(this.constructor.name);
30
- this.debug = createDebugger('tsRestRouter', serviceName).withoutEnvNs();
31
- const debug = this.debug.withNs('constructor').withHash();
32
- debug('Service created.');
12
+ super(container, {
13
+ namespace: 'tsRestRouter',
14
+ noEnvironmentNamespace: true,
15
+ });
33
16
  }
34
17
  }
@@ -1,4 +1,4 @@
1
- export * from './utils/index.js';
1
+ export * from '@e22m4u/js-trie-router';
2
2
  export * from './rest-router.js';
3
3
  export * from './errors/index.js';
4
4
  export * from './decorators/index.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './utils/index.js';
1
+ export * from '@e22m4u/js-trie-router';
2
2
  export * from './rest-router.js';
3
3
  export * from './errors/index.js';
4
4
  export * from './decorators/index.js';
@@ -1,4 +1,6 @@
1
1
  import { Constructor } from './types.js';
2
+ import { HookType } from '@e22m4u/js-trie-router';
3
+ import { RouterHook } from '@e22m4u/js-trie-router';
2
4
  import { DebuggableService } from './debuggable-service.js';
3
5
  import { ControllerRootOptions } from './controller-registry.js';
4
6
  /**
@@ -16,4 +18,11 @@ export declare class RestRouter extends DebuggableService {
16
18
  * @param options
17
19
  */
18
20
  addController<T extends object>(ctor: Constructor<T>, options?: ControllerRootOptions): this;
21
+ /**
22
+ * Add hook.
23
+ *
24
+ * @param type
25
+ * @param hook
26
+ */
27
+ addHook(type: HookType, hook: RouterHook): this;
19
28
  }
@@ -21,4 +21,14 @@ export class RestRouter extends DebuggableService {
21
21
  this.getService(ControllerRegistry).addController(ctor, options);
22
22
  return this;
23
23
  }
24
+ /**
25
+ * Add hook.
26
+ *
27
+ * @param type
28
+ * @param hook
29
+ */
30
+ addHook(type, hook) {
31
+ this.getService(TrieRouter).addHook(type, hook);
32
+ return this;
33
+ }
24
34
  }
@@ -1,3 +1 @@
1
1
  export * from './capitalize.js';
2
- export * from './create-error.js';
3
- export * from './to-camel-case.js';
@@ -1,3 +1 @@
1
1
  export * from './capitalize.js';
2
- export * from './create-error.js';
3
- export * from './to-camel-case.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/ts-rest-router",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Декларативный REST-маршрутизатор на основе контроллеров для TypeScript",
5
5
  "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -43,34 +43,34 @@
43
43
  "dependencies": {
44
44
  "@e22m4u/js-debug": "~0.3.1",
45
45
  "@e22m4u/js-format": "~0.2.0",
46
- "@e22m4u/js-service": "~0.4.0",
46
+ "@e22m4u/js-service": "~0.4.2",
47
47
  "@e22m4u/js-trie-router": "~0.3.1",
48
- "@e22m4u/ts-data-schema": "~0.4.3",
49
- "@e22m4u/ts-reflector": "~0.1.7",
48
+ "@e22m4u/ts-data-schema": "~0.4.4",
49
+ "@e22m4u/ts-reflector": "~0.1.8",
50
50
  "http-errors": "~2.0.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@commitlint/cli": "~20.1.0",
54
54
  "@commitlint/config-conventional": "~20.0.0",
55
- "@eslint/js": "~9.36.0",
55
+ "@eslint/js": "~9.37.0",
56
56
  "@types/chai": "~5.2.2",
57
57
  "@types/debug": "~4.1.12",
58
58
  "@types/http-errors": "~2.0.5",
59
59
  "@types/mocha": "~10.0.10",
60
- "@types/node": "~24.6.1",
60
+ "@types/node": "~24.7.0",
61
61
  "c8": "~10.1.3",
62
62
  "chai": "~6.2.0",
63
63
  "esbuild": "~0.25.10",
64
- "eslint": "~9.36.0",
64
+ "eslint": "~9.37.0",
65
65
  "eslint-config-prettier": "~10.1.8",
66
66
  "eslint-plugin-chai-expect": "~3.1.0",
67
- "eslint-plugin-mocha": "~11.1.0",
67
+ "eslint-plugin-mocha": "~11.2.0",
68
68
  "husky": "~9.1.7",
69
- "mocha": "~11.7.3",
69
+ "mocha": "~11.7.4",
70
70
  "prettier": "~3.6.2",
71
71
  "rimraf": "~6.0.1",
72
72
  "tsx": "~4.20.6",
73
73
  "typescript": "~5.9.3",
74
- "typescript-eslint": "~8.45.0"
74
+ "typescript-eslint": "~8.46.0"
75
75
  }
76
76
  }
@@ -1,5 +1,4 @@
1
1
  import {expect} from 'chai';
2
- import {Service} from '@e22m4u/js-service';
3
2
  import {DebuggableService} from './debuggable-service.js';
4
3
 
5
4
  describe('DebuggableService', function () {
@@ -7,11 +6,4 @@ describe('DebuggableService', function () {
7
6
  const res = new DebuggableService();
8
7
  expect(typeof res.debug).to.be.eq('function');
9
8
  });
10
-
11
- describe('constructor', function () {
12
- it('extends the Service class', function () {
13
- const res = new DebuggableService();
14
- expect(res).to.be.instanceof(Service);
15
- });
16
- });
17
9
  });
@@ -1,40 +1,19 @@
1
- import {Callable} from './types.js';
2
- import {Debugger} from '@e22m4u/js-debug';
3
- import {Service} from '@e22m4u/js-service';
4
- import {toCamelCase} from './utils/index.js';
5
- import {createDebugger} from '@e22m4u/js-debug';
6
1
  import {ServiceContainer} from '@e22m4u/js-service';
2
+ import {DebuggableService as BaseDebuggableService} from '@e22m4u/js-service';
7
3
 
8
4
  /**
9
- * Service.
5
+ * Base debuggable service.
10
6
  */
11
- export class DebuggableService extends Service {
12
- /**
13
- * Debug.
14
- */
15
- debug: Debugger;
16
-
17
- /**
18
- * Возвращает функцию-отладчик с сегментом пространства имен
19
- * указанного в параметре метода.
20
- *
21
- * @param method
22
- * @protected
23
- */
24
- protected getDebuggerFor(method: Callable) {
25
- return this.debug.withHash().withNs(method.name);
26
- }
27
-
7
+ export class DebuggableService extends BaseDebuggableService {
28
8
  /**
29
9
  * Constructor.
30
10
  *
31
11
  * @param container
32
12
  */
33
13
  constructor(container?: ServiceContainer) {
34
- super(container);
35
- const serviceName = toCamelCase(this.constructor.name);
36
- this.debug = createDebugger('tsRestRouter', serviceName).withoutEnvNs();
37
- const debug = this.debug.withNs('constructor').withHash();
38
- debug('Service created.');
14
+ super(container, {
15
+ namespace: 'tsRestRouter',
16
+ noEnvironmentNamespace: true,
17
+ });
39
18
  }
40
19
  }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './utils/index.js';
1
+ export * from '@e22m4u/js-trie-router';
2
+
2
3
  export * from './rest-router.js';
3
4
  export * from './errors/index.js';
4
5
  export * from './decorators/index.js';
@@ -1,4 +1,6 @@
1
1
  import {Constructor} from './types.js';
2
+ import {HookType} from '@e22m4u/js-trie-router';
3
+ import {RouterHook} from '@e22m4u/js-trie-router';
2
4
  import {TrieRouter} from '@e22m4u/js-trie-router';
3
5
  import {DebuggableService} from './debuggable-service.js';
4
6
  import {ControllerRegistry} from './controller-registry.js';
@@ -28,4 +30,15 @@ export class RestRouter extends DebuggableService {
28
30
  this.getService(ControllerRegistry).addController(ctor, options);
29
31
  return this;
30
32
  }
33
+
34
+ /**
35
+ * Add hook.
36
+ *
37
+ * @param type
38
+ * @param hook
39
+ */
40
+ addHook(type: HookType, hook: RouterHook) {
41
+ this.getService(TrieRouter).addHook(type, hook);
42
+ return this;
43
+ }
31
44
  }
@@ -1,3 +1 @@
1
1
  export * from './capitalize.js';
2
- export * from './create-error.js';
3
- export * from './to-camel-case.js';
@@ -1,10 +0,0 @@
1
- import { Constructor } from '../types.js';
2
- /**
3
- * Create error.
4
- *
5
- * @param {Function} errorCtor
6
- * @param {string} message
7
- * @param {*[]|undefined} args
8
- * @returns {object}
9
- */
10
- export declare function createError<T>(errorCtor: Constructor<T>, message: string, ...args: unknown[]): T;
@@ -1,13 +0,0 @@
1
- import { format } from '@e22m4u/js-format';
2
- /**
3
- * Create error.
4
- *
5
- * @param {Function} errorCtor
6
- * @param {string} message
7
- * @param {*[]|undefined} args
8
- * @returns {object}
9
- */
10
- export function createError(errorCtor, message, ...args) {
11
- const interpolatedMessage = format(message, ...args);
12
- return new errorCtor(interpolatedMessage);
13
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { expect } from 'chai';
2
- import { createError } from './create-error.js';
3
- describe('createError', function () {
4
- it('interpolates the given message with arguments', function () {
5
- const res = createError(Error, 'My %s', 'message');
6
- expect(res.message).to.be.eq('My message');
7
- });
8
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * To camel case.
3
- *
4
- * @param input
5
- */
6
- export declare function toCamelCase(input: string): string;
@@ -1,11 +0,0 @@
1
- /**
2
- * To camel case.
3
- *
4
- * @param input
5
- */
6
- export function toCamelCase(input) {
7
- return input
8
- .replace(/(^\w|[A-Z]|\b\w)/g, c => c.toUpperCase())
9
- .replace(/\W+/g, '')
10
- .replace(/(^\w)/g, c => c.toLowerCase());
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { expect } from 'chai';
2
- import { toCamelCase } from './to-camel-case.js';
3
- describe('toCamelCase', function () {
4
- it('returns a camelCase string', function () {
5
- expect(toCamelCase('TestString')).to.be.eq('testString');
6
- expect(toCamelCase('test-string')).to.be.eq('testString');
7
- expect(toCamelCase('test string')).to.be.eq('testString');
8
- expect(toCamelCase('Test string')).to.be.eq('testString');
9
- });
10
- });
@@ -1,9 +0,0 @@
1
- import {expect} from 'chai';
2
- import {createError} from './create-error.js';
3
-
4
- describe('createError', function () {
5
- it('interpolates the given message with arguments', function () {
6
- const res = createError(Error, 'My %s', 'message');
7
- expect(res.message).to.be.eq('My message');
8
- });
9
- });
@@ -1,19 +0,0 @@
1
- import {Constructor} from '../types.js';
2
- import {format} from '@e22m4u/js-format';
3
-
4
- /**
5
- * Create error.
6
- *
7
- * @param {Function} errorCtor
8
- * @param {string} message
9
- * @param {*[]|undefined} args
10
- * @returns {object}
11
- */
12
- export function createError<T>(
13
- errorCtor: Constructor<T>,
14
- message: string,
15
- ...args: unknown[]
16
- ): T {
17
- const interpolatedMessage = format(message, ...args);
18
- return new errorCtor(interpolatedMessage);
19
- }
@@ -1,11 +0,0 @@
1
- import {expect} from 'chai';
2
- import {toCamelCase} from './to-camel-case.js';
3
-
4
- describe('toCamelCase', function () {
5
- it('returns a camelCase string', function () {
6
- expect(toCamelCase('TestString')).to.be.eq('testString');
7
- expect(toCamelCase('test-string')).to.be.eq('testString');
8
- expect(toCamelCase('test string')).to.be.eq('testString');
9
- expect(toCamelCase('Test string')).to.be.eq('testString');
10
- });
11
- });
@@ -1,11 +0,0 @@
1
- /**
2
- * To camel case.
3
- *
4
- * @param input
5
- */
6
- export function toCamelCase(input: string): string {
7
- return input
8
- .replace(/(^\w|[A-Z]|\b\w)/g, c => c.toUpperCase())
9
- .replace(/\W+/g, '')
10
- .replace(/(^\w)/g, c => c.toLowerCase());
11
- }