-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename arrays to lists and maps to dictionaries
- Loading branch information
1 parent
b4fae29
commit 97c4ee5
Showing
39 changed files
with
218 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function isDictionaryOf<X extends {}, Y>(obj: X, typeGuard: (value: unknown) => value is Y): obj is X & { [key: string]: Y } { | ||
for (const key in obj) { | ||
if (!typeGuard(obj[key])) return false; | ||
} | ||
return true; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {DictionaryType} from "../types"; | ||
import {booleanType} from "./booleanType"; | ||
|
||
export const booleanDictionaryType = new DictionaryType(booleanType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {ListType} from "../types"; | ||
import {booleanType} from "./booleanType"; | ||
|
||
export const booleanListType = new ListType(booleanType) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export * from './stringType' | ||
export * from './numberType' | ||
export * from './booleanType' | ||
export * from './stringArrayType' | ||
export * from './numberArrayType' | ||
export * from './booleanArrayType' | ||
export * from './stringMapType' | ||
export * from './numberMapType' | ||
export * from './booleanMapType' | ||
export * from './stringListType' | ||
export * from './numberListType' | ||
export * from './booleanListType' | ||
export * from './stringDictionaryType' | ||
export * from './numberDictionaryType' | ||
export * from './booleanDictionaryType' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {DictionaryType} from "../types"; | ||
import {numberType} from "./numberType"; | ||
|
||
export const numberDictionaryType = new DictionaryType(numberType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {ListType} from "../types"; | ||
import {numberType} from "./numberType"; | ||
|
||
export const numberListType = new ListType(numberType) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {DictionaryType} from "../types"; | ||
import {stringType} from "./stringType"; | ||
|
||
export const stringDictionaryType = new DictionaryType(stringType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {ListType} from "../types"; | ||
import {stringType} from "./stringType"; | ||
|
||
export const stringListType = new ListType(stringType) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
templates/MapType.guard.ts.mustache → templates/DictionaryType.guard.ts.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function is{{{name}}}(value: unknown): value is {{{name}}} { | ||
if (!(typeof value === "object")) return false; | ||
if (value === null) return false; | ||
return isMapOf(value, is{{{type}}}); | ||
return isDictionaryOf(value, is{{{type}}}); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {booleanDictionaryType, DictionaryType, booleanType} from "../../../src" | ||
|
||
const GENERATED_TYPE_NAME_REGEXP = new RegExp('^__TTG_Anonymous_Dictionary_[0-9]+$') | ||
|
||
describe('booleanDictionaryType', () => { | ||
it('should be a DictionaryType', () => { | ||
booleanDictionaryType.should.be.an.instanceOf(DictionaryType); | ||
}) | ||
|
||
it('should have the correct name', () => { | ||
booleanDictionaryType.getName().should.match(GENERATED_TYPE_NAME_REGEXP) | ||
}) | ||
|
||
it('should not be exported', () => { | ||
booleanDictionaryType.isExported().should.be.false | ||
}) | ||
|
||
it('should be an array of booleans', () => { | ||
booleanDictionaryType.type.should.equal(booleanType); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {booleanListType, ListType, booleanType} from "../../../src" | ||
|
||
const GENERATED_TYPE_NAME_REGEXP = new RegExp('^__TTG_Anonymous_List_[0-9]+$') | ||
|
||
describe('booleanListType', () => { | ||
it('should be a ListType', () => { | ||
booleanListType.should.be.an.instanceOf(ListType); | ||
}) | ||
|
||
it('should have the correct name', () => { | ||
booleanListType.getName().should.match(GENERATED_TYPE_NAME_REGEXP) | ||
}) | ||
|
||
it('should not be exported', () => { | ||
booleanListType.isExported().should.be.false | ||
}) | ||
|
||
it('should be an array of booleans', () => { | ||
booleanListType.type.should.equal(booleanType); | ||
}) | ||
}) |
Oops, something went wrong.