Skip to content

Commit

Permalink
Remove usage of Array.prototype.includes to support IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
Neos3452 committed Oct 28, 2019
1 parent a749955 commit 38b57d8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
7 changes: 1 addition & 6 deletions js/typedjson.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/typedjson.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/typedjson.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/typedjson.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/typedjson/options-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export interface OptionsBase {
*/
preserveNull?: boolean;
}
export declare function extractOptionBase(from: any): OptionsBase | undefined;
export declare function extractOptionBase(from: {
[key: string]: any;
} & OptionsBase): OptionsBase | undefined;
export declare function getDefaultOptionOf<K extends keyof OptionsBase>(key: K): Required<OptionsBase>[K];
export declare function getOptionValue<K extends keyof OptionsBase>(key: K, options?: OptionsBase): Required<OptionsBase>[K];
export declare function mergeOptions(existing?: OptionsBase, moreSpecific?: OptionsBase): OptionsBase | undefined;
5 changes: 2 additions & 3 deletions src/typedjson/options-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* in the more specific place override the previous option.
* Ex. @jsonMember overrides TypedJson options.
*/

export interface OptionsBase {
/**
* Whether to preserve null in the JSON output. When false it
Expand All @@ -17,9 +16,9 @@ const kAllOptions: (keyof OptionsBase)[] = [
'preserveNull',
];

export function extractOptionBase(from: any): OptionsBase|undefined {
export function extractOptionBase(from: {[key: string]: any} & OptionsBase): OptionsBase|undefined {
const options = Object.keys(from)
.filter(key => (kAllOptions as string[]).includes(key))
.filter(key => (kAllOptions as string[]).indexOf(key) > -1)
.reduce((obj, key) => {
obj[key] = from[key];
return obj;
Expand Down

0 comments on commit 38b57d8

Please sign in to comment.