Skip to content

Commit 0318343

Browse files
authored
Merge pull request #5 from typescript-package/develop
v2.1.0
2 parents 889fe45 + c87b389 commit 0318343

File tree

9 files changed

+65
-8
lines changed

9 files changed

+65
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ A **lightweight** TypeScript library for the affix - prefix and suffix.
2020

2121
- [Installation](#installation)
2222
- [Api](#api)
23+
- [`Affix`](#affix)
24+
- [`Prefix`](#prefix)
25+
- [`Suffix`](#suffix)
2326
- [Contributing](#contributing)
2427
- [Support](#support)
2528
- [Code of Conduct](#code-of-conduct)

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typescript-package/affix",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"author": "wwwdev.io <dev@wwwdev.io>",
55
"description": "A lightweight TypeScript library for the affix - prefix and suffix.",
66
"license": "MIT",
@@ -9,7 +9,7 @@
99
"registry": "https://registry.npmjs.org"
1010
},
1111
"peerDependencies": {
12-
"@typescript-package/core": "^1.2.0"
12+
"@typescript-package/core": "^2.0.0"
1313
},
1414
"scripts": {
1515
"prepublishOnly": "npm run pkg && npm run clean",

src/lib/affix.abstract.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import { Value } from '@typescript-package/core';
99
* @extends {Value<Value>}
1010
*/
1111
export abstract class Affix<Value extends string = string> extends Value<Value> {
12+
/**
13+
* @description Returns the `string` tag representation of the `Affix` class when used in `Object.prototype.toString.call(instance)`.
14+
* @public
15+
* @readonly
16+
* @type {string}
17+
*/
18+
public override get [Symbol.toStringTag]() {
19+
return 'Affix';
20+
}
21+
1222
/**
1323
* @description Defines the affix sanitized by specified pattern.
1424
* @public
@@ -87,6 +97,7 @@ export abstract class Affix<Value extends string = string> extends Value<Value>
8797
* @description Sets the pattern to sanitize the affix.
8898
* @public
8999
* @param {RegExp} pattern The pattern of `RegExp` to sanitize the affix.
100+
* @returns {this}
90101
*/
91102
public setPattern(pattern: RegExp): this {
92103
pattern instanceof RegExp && (this.#pattern = pattern);

src/lib/prefix.class.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ import { Affix } from "./affix.abstract";
88
* @extends {Affix<Value>}
99
*/
1010
export class Prefix<Value extends string = string> extends Affix<Value> {
11+
/**
12+
* @description Returns the `string` tag representation of the `Prefix` class when used in `Object.prototype.toString.call(instance)`.
13+
* @public
14+
* @readonly
15+
* @type {string}
16+
*/
17+
public override get [Symbol.toStringTag]() {
18+
return 'Prefix';
19+
}
20+
1121
/**
1222
* @description Sanitizes the prefix with a `pattern`.
1323
* @public

src/lib/suffix.class.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ import { Affix } from "./affix.abstract";
88
* @extends {Affix<Value>}
99
*/
1010
export class Suffix<Value extends string = string> extends Affix<Value> {
11+
/**
12+
* @description Returns the `string` tag representation of the `Suffix` class when used in `Object.prototype.toString.call(instance)`.
13+
* @public
14+
* @readonly
15+
* @type {string}
16+
*/
17+
public override get [Symbol.toStringTag]() {
18+
return 'Suffix';
19+
}
20+
1121
/**
1222
* @description Sanitizes the suffix with a `pattern`.
1323
* @public

src/test/affix.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { typeOf } from "@typescript-package/core";
2+
import { Affix } from "../lib";
3+
4+
export class TestAffix extends Affix {}
5+
6+
const testAffix = new TestAffix();
7+
8+
console.log(testAffix);
9+
console.log(`typeOf(), `, typeOf(testAffix));
10+
console.log(`[object Affix], `, Object.prototype.toString.call(testAffix).match(/\[object (\w+)]/)?.[1]);

src/test/prefix.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
import { typeOf } from '@typescript-package/core';
12
import { Prefix } from '../lib/prefix.class';
23

34
const prefix = new Prefix();
45

56
console.group(`Prefix`);
7+
console.log(prefix);
68

79
console.debug(`set('_')`, prefix.set('_'));
810
console.debug(`get()`, prefix.get());
911
console.debug(`value`, prefix.value);
1012

13+
console.log(`typeOf(), `, typeOf(prefix));
14+
console.log(`[object Suffix], `, Object.prototype.toString.call(prefix));
15+
1116
console.groupEnd();
1217

1318
describe(Prefix.name, () => {

src/test/suffix.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { typeOf } from "@typescript-package/core";
2+
import { Suffix } from "../lib";
3+
4+
const suffix = new Suffix();
5+
6+
console.log(suffix);
7+
console.log(`typeOf(), `, typeOf(suffix));
8+
console.log(`[object Suffix], `, Object.prototype.toString.call(suffix));

0 commit comments

Comments
 (0)