Skip to content

Commit cb71e93

Browse files
Update dependencies
1 parent fd40ace commit cb71e93

File tree

8 files changed

+1235
-1370
lines changed

8 files changed

+1235
-1370
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# WebStorm
2-
.idea/
1+
# Visual Studio Code
2+
.vscode/
33

44
# JavaScript and TypeScript
55
lib/

.travis.yml

-8
This file was deleted.

package-lock.json

+1,209-1,276
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"clean-docs": "rimraf docs",
4040
"clean-test": "rimraf test/lib",
4141
"dev": "npm run-script clean && npm run-script lint && tsc -p tsconfig.json --sourceMap",
42-
"docs": "npm run-script clean-docs && typedoc --mode file --module commonjs --out docs --target es5 --tsconfig tsconfig.json",
42+
"docs": "npm run-script clean-docs && typedoc src/main.ts",
4343
"lint": "eslint . --ext .ts",
4444
"prod": "npm run-script clean && npm run-script lint && tsc -p tsconfig.json",
4545
"test-dev": "npm run-script clean-test && tsc -p test/tsconfig.json --sourceMap && mocha test/lib",
@@ -49,15 +49,15 @@
4949
"xmlcreate": "^2.0.3"
5050
},
5151
"devDependencies": {
52-
"@types/chai": "^4.2.8",
53-
"@types/mocha": "^7.0.1",
54-
"@typescript-eslint/eslint-plugin": "^2.18.0",
55-
"@typescript-eslint/parser": "^2.18.0",
52+
"@types/chai": "^4.2.14",
53+
"@types/mocha": "^8.2.0",
54+
"@typescript-eslint/eslint-plugin": "^4.14.0",
55+
"@typescript-eslint/parser": "^4.14.0",
5656
"chai": "^4.2.0",
57-
"eslint": "^6.8.0",
58-
"mocha": "^7.0.1",
59-
"rimraf": "^3.0.1",
60-
"typedoc": "^0.16.9",
61-
"typescript": "^3.7.5"
57+
"eslint": "^7.18.0",
58+
"mocha": "^8.2.1",
59+
"rimraf": "^3.0.2",
60+
"typedoc": "^0.20.17",
61+
"typescript": "^4.1.3"
6262
}
6363
}

src/main.ts

+11-17
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ import {
2525
stringify
2626
} from "./utils";
2727

28+
export {
29+
IOptions,
30+
IDeclarationOptions,
31+
IDtdOptions,
32+
ITypeHandlers,
33+
IWrapHandlers,
34+
} from "./options";
35+
2836
/**
2937
* Indicates that an object of a particular type should be suppressed from the
3038
* XML output.
@@ -40,15 +48,13 @@ export class Absent {
4048
/**
4149
* Returns the sole instance of Absent.
4250
*/
43-
public static get instance() {
51+
public static get instance(): Absent {
4452
return Absent._instance;
4553
}
4654
}
4755

4856
/**
4957
* Gets the type handler associated with a value.
50-
*
51-
* @private
5258
*/
5359
function getHandler(value: unknown,
5460
options: Options): ((value: unknown) => unknown) | undefined
@@ -66,8 +72,6 @@ function getHandler(value: unknown,
6672

6773
/**
6874
* Parses a string into XML and adds it to the parent element or attribute.
69-
*
70-
* @private
7175
*/
7276
function parseString(str: string,
7377
parentElement: XmlAttribute<unknown> | XmlElement<unknown>,
@@ -126,8 +130,6 @@ function parseString(str: string,
126130

127131
/**
128132
* Parses an attribute into XML and adds it to the parent element.
129-
*
130-
* @private
131133
*/
132134
function parseAttribute(name: string, value: string,
133135
parentElement: XmlElement<unknown>,
@@ -143,8 +145,6 @@ function parseAttribute(name: string, value: string,
143145

144146
/**
145147
* Parses an object or Map entry into XML and adds it to the parent element.
146-
*
147-
* @private
148148
*/
149149
function parseObjectOrMapEntry(key: string, value: unknown,
150150
parentElement: XmlElement<unknown>,
@@ -194,8 +194,6 @@ function parseObjectOrMapEntry(key: string, value: unknown,
194194

195195
/**
196196
* Parses an Object or Map into XML and adds it to the parent element.
197-
*
198-
* @private
199197
*/
200198
function parseObjectOrMap(
201199
objectOrMap: Record<string, unknown> | Map<unknown, unknown>,
@@ -217,8 +215,6 @@ function parseObjectOrMap(
217215

218216
/**
219217
* Parses an array or Set into XML and adds it to the parent element.
220-
*
221-
* @private
222218
*/
223219
function parseArrayOrSet(key: string, arrayOrSet: unknown[] | Set<unknown>,
224220
parentElement: XmlElement<unknown>,
@@ -275,8 +271,6 @@ function parseArrayOrSet(key: string, arrayOrSet: unknown[] | Set<unknown>,
275271
/**
276272
* Parses an arbitrary JavaScript value into XML and adds it to the parent
277273
* element.
278-
*
279-
* @private
280274
*/
281275
function parseValue(key: string, value: unknown,
282276
parentElement: XmlElement<unknown>,
@@ -303,15 +297,15 @@ function parseValue(key: string, value: unknown,
303297

304298
/**
305299
* Converts the specified object to XML and adds the XML representation to the
306-
* specified XmlDocument object using the specified options.
300+
* specified XmlElement object using the specified options.
307301
*
308302
* This function does not add a root element. In addition, it does not add an
309303
* XML declaration or DTD, and the associated options in {@link IOptions} are
310304
* ignored. If desired, these must be added manually.
311305
*/
312306
export function parseToExistingElement(element: XmlElement<unknown>,
313307
object: unknown,
314-
options?: IOptions)
308+
options?: IOptions): void
315309
{
316310
const opts: Options = new Options(options);
317311
parseValue(element.name, object, element, opts);

src/options.ts

-12
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ export interface IOptions {
299299
/**
300300
* Implementation of the IOptions interface used to provide default values
301301
* to fields.
302-
*
303-
* @private
304302
*/
305303
export class Options implements IOptions {
306304
public aliasString = "=";
@@ -398,8 +396,6 @@ export interface IDeclarationOptions {
398396
/**
399397
* Implementation of the IDeclarationOptions interface used to provide default
400398
* values to fields.
401-
*
402-
* @private
403399
*/
404400
export class DeclarationOptions implements IDeclarationOptions {
405401
public include = true;
@@ -455,8 +451,6 @@ export interface IDtdOptions {
455451
/**
456452
* Implementation of the IDtdOptions interface used to provide default values
457453
* to fields.
458-
*
459-
* @private
460454
*/
461455
export class DtdOptions implements IDtdOptions {
462456
public include = false;
@@ -509,8 +503,6 @@ export interface IFormatOptions {
509503
/**
510504
* Implementation of the IFormatOptions interface used to provide default values
511505
* to fields.
512-
*
513-
* @private
514506
*/
515507
export class FormatOptions implements IFormatOptions {
516508
public doubleQuotes?: boolean;
@@ -541,8 +533,6 @@ export interface ITypeHandlers {
541533
/**
542534
* Implementation of the ITypeHandlers interface used to provide default values
543535
* to fields.
544-
*
545-
* @private
546536
*/
547537
export class TypeHandlers implements ITypeHandlers {
548538
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -577,8 +567,6 @@ export interface IWrapHandlers {
577567
/**
578568
* Implementation of the IWrapHandlers interface used to provide default values
579569
* to fields.
580-
*
581-
* @private
582570
*/
583571
export class WrapHandlers implements IWrapHandlers {
584572
// eslint-disable-next-line @typescript-eslint/no-explicit-any

src/utils.ts

+3-29
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,26 @@
1414
* limitations under the License.
1515
*/
1616

17-
/**
18-
* @private
19-
*/
2017
export function isUndefined(val: unknown): val is undefined {
2118
return Object.prototype.toString.call(val) === "[object Undefined]";
2219
}
2320

24-
/**
25-
* @private
26-
*/
2721
export function isNull(val: unknown): val is null {
2822
return Object.prototype.toString.call(val) === "[object Null]";
2923
}
3024

31-
/**
32-
* @private
33-
*/
3425
export function isObject(val: unknown): val is Record<string, unknown> {
3526
return Object.prototype.toString.call(val) === "[object Object]";
3627
}
3728

38-
/**
39-
* @private
40-
*/
4129
export function isArray(val: unknown): val is unknown[] {
4230
return Object.prototype.toString.call(val) === "[object Array]";
4331
}
4432

45-
/**
46-
* @private
47-
*/
48-
export function isFunction(val: unknown): val is Function {
49-
return Object.prototype.toString.call(val) === "[object Function]";
50-
}
51-
52-
/**
53-
* @private
54-
*/
5533
export function isSet(val: unknown): val is Set<unknown> {
5634
return Object.prototype.toString.call(val) === "[object Set]";
5735
}
5836

59-
/**
60-
* @private
61-
*/
6237
export function isMap(val: unknown): val is Map<unknown, unknown> {
6338
return Object.prototype.toString.call(val) === "[object Map]";
6439
}
@@ -71,13 +46,12 @@ export function isMap(val: unknown): val is Map<unknown, unknown> {
7146
* @param value The value to convert to a string.
7247
*
7348
* @returns A string representation of the specified value.
74-
*
75-
* @private
7649
*/
77-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50+
// eslint-disable-next-line max-len
51+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
7852
export function stringify(value: any): string {
7953
if (!isUndefined(value) && !isNull(value)) {
80-
if (!isFunction(value?.toString)) {
54+
if (value?.toString) {
8155
value = value.toString();
8256
}
8357
}

test/src/utils.ts

-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import {assert} from "chai";
1818
import {
1919
isArray,
20-
isFunction,
2120
isMap,
2221
isNull,
2322
isObject,
@@ -84,21 +83,6 @@ describe("utils", () => {
8483
});
8584
});
8685

87-
describe("#isFunction", () => {
88-
it("should return true for functions", () => {
89-
assert.isTrue(isFunction(() => 0));
90-
assert.isTrue(isFunction(() => "test"));
91-
});
92-
93-
it("should return false for values that are not functions", () => {
94-
assert.isFalse(isFunction("test"));
95-
assert.isFalse(isFunction(3));
96-
assert.isFalse(isFunction(undefined));
97-
assert.isFalse(isFunction(true));
98-
assert.isFalse(isFunction(null));
99-
});
100-
});
101-
10286
describe("#isSet", () => {
10387
it("should return true for sets", () => {
10488
assert.isTrue(isSet(new Set()));

0 commit comments

Comments
 (0)