Skip to content

Commit 1f6c8da

Browse files
committed
Added a proxy for the method of the dependent library.
1 parent d09b5e5 commit 1f6c8da

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ The marshalled version of the input data.
5353

5454
## Changelog:
5555

56+
**v1.14.0**:
57+
58+
- Added a proxy for the `getTypeOf` method of the dependent `typeDetector` library.
59+
5660
**v1.13.0**:
5761

5862
- Small fixes to the function regexes.

src/Marshaller.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {IMarshaller, Newable} from "./interface/IMarshaller";
2-
import {ITypeDetector, IArbitraryObject} from "@wessberg/typedetector";
2+
import {ITypeDetector, IArbitraryObject, TypeOf} from "@wessberg/typedetector";
33

44
/**
55
* A class that maps between a variety of data types.
@@ -26,6 +26,15 @@ export class Marshaller implements IMarshaller {
2626
else return <U | null>this.marshalToBestGuess<T>(data);
2727
}
2828

29+
/**
30+
* A proxy for the 'getTypeOf' operation of the typeDetector.
31+
* @param {T} data
32+
* @returns {TypeOf}
33+
*/
34+
public getTypeOf<T> (data: T): TypeOf {
35+
return this.typeDetector.getTypeof(data);
36+
}
37+
2938
/**
3039
* Marshals a string into null.
3140
* @param {string} _
@@ -989,7 +998,7 @@ export class Marshaller implements IMarshaller {
989998
if (typeof to === null) return this.marshalToNull(data);
990999
if (typeof to === "symbol" || to === Symbol) return this.marshalToSymbol(data);
9911000
if (this.typeDetector.isString(to) || to === String) return this.marshalToString(data);
992-
if (data instanceof Set || to === Set) return this.marshalToSet(data);
1001+
if (to instanceof Set || to === Set) return this.marshalToSet(data);
9931002
if (Array.isArray(to) || to === Array) return this.marshalToArray(data);
9941003
if (this.typeDetector.isObject(to) || to === Object) return this.marshalToObject(data);
9951004
if (this.typeDetector.isBoolean(to) || to === Boolean) return this.marshalToBoolean(data);

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
export {TypeOf} from '@wessberg/typedetector';
12
export {IMarshaller, Newable} from "./interface/IMarshaller";
23
export {Marshaller} from "./Marshaller";

0 commit comments

Comments
 (0)