Merge pull request #884 from quicktype/update-collection-utils

Update collection-utils
This commit is contained in:
Mark Probst 2018-06-07 08:15:03 -07:00 коммит произвёл GitHub
Родитель 65203b4194 6acab7c8c9
Коммит e720b518e3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 125 добавлений и 140 удалений

8
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "quicktype",
"version": "14.0.0",
"version": "15.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1350,9 +1350,9 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"collection-utils": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/collection-utils/-/collection-utils-0.0.7.tgz",
"integrity": "sha512-dV3WboXlSs44BiRlhGLjsMYU0fJzfT3DXqBJuX6W2cPXftrfoFzEoMeWXNVoR4/vjtGtLW/t01JlQsTUPJdGEA==",
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/collection-utils/-/collection-utils-0.0.8.tgz",
"integrity": "sha512-YqbhLvBv6rQpy+Rzr2GhuOfQr0/wgk+PW9CSQjjb/lMiZfINgF9uPV/fZ4hWkKyc0Oycmfk6nMqAFVQ5z27Rvw==",
"requires": {
"@types/string-hash": "^1.1.1",
"string-hash": "^1.1.3"

Просмотреть файл

@ -1,90 +1,97 @@
{
"name": "quicktype",
"name": "quicktype",
"version": "15.0.0",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"pub": "script/publish.sh",
"prepare": "npm run build",
"build": "script/build.ts",
"test": "jest && script/test",
"start": "script/watch",
"pkg": "script/make-pkgs.sh",
"tslint":
"tslint --project src/cli --exclude 'src/__tests__/**' --exclude 'src/quicktype-core/get-stream/**'",
"clean": "rm -rf dist node_modules *~"
},
"dependencies": {
"chalk": "^2.4.1",
"collection-utils": "0.0.7",
"command-line-args": "^4.0.6",
"command-line-usage": "^4.1.0",
"graphql": "^0.11.7",
"is-url": "^1.2.4",
"js-base64": "^2.4.3",
"lodash": "^4.17.10",
"moment": "^2.22.1",
"node-fetch": "^1.7.1",
"node-persist": "^2.1.0",
"pako": "^1.0.6",
"pluralize": "^7.0.0",
"stream-json": "0.5.2",
"string-hash": "^1.1.3",
"string-to-stream": "^1.1.0",
"typescript-json-schema":
"quicktype/typescript-json-schema#d16083d29c8b6702c666a981fa6b21113300c059",
"unicode-properties": "github:quicktype/unicode-properties#dist",
"universal-analytics": "^0.4.16",
"urijs": "^1.19.1",
"uuid": "^3.2.1"
},
"devDependencies": {
"@types/urijs": "github:quicktype/types-urijs",
"@types/string-hash": "^1.1.1",
"@types/is-url": "^1.2.28",
"@types/jest": "^22.2.0",
"@types/lodash": "^4.14.108",
"@types/node": "^8.10.10",
"@types/node-persist": "0.0.33",
"@types/shelljs": "^0.7.8",
"@types/universal-analytics": "^0.4.2",
"@types/semver": "^5.5.0",
"ajv": "^5.5.2",
"deep-equal": "^1.0.1",
"elm": "^0.18.0",
"exit": "^0.1.2",
"flow-bin": "^0.66.0",
"flow-remove-types": "^1.2.3",
"jest": "^22.4.3",
"pkg": "^4.3.1",
"promise-timeout": "^1.3.0",
"semver": "^5.5.0",
"shelljs": "^0.7.8",
"ts-jest": "^22.4.2",
"ts-node": "^3.3.0",
"tslint": "^5.9.1",
"typescript": "~2.8.3",
"uglify-js": "^3.3.22",
"watch": "^1.0.2",
"@types/graphql": "^0.11.7",
"@types/js-base64": "^2.3.1",
"@types/pako": "^1.0.0",
"@types/pluralize": "0.0.28"
},
"files": ["dist/**"],
"bin": "dist/cli/index.js",
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"pub": "script/publish.sh",
"prepare": "npm run build",
"build": "script/build.ts",
"test": "jest && script/test",
"start": "script/watch",
"pkg": "script/make-pkgs.sh",
"tslint": "tslint --project src/cli --exclude 'src/__tests__/**' --exclude 'src/quicktype-core/get-stream/**'",
"clean": "rm -rf dist node_modules *~"
},
"globals": {
"ts-jest": {
"tsConfigFile": "src/cli/tsconfig.json"
}
"dependencies": {
"chalk": "^2.4.1",
"collection-utils": "0.0.8",
"command-line-args": "^4.0.6",
"command-line-usage": "^4.1.0",
"graphql": "^0.11.7",
"is-url": "^1.2.4",
"js-base64": "^2.4.3",
"lodash": "^4.17.10",
"moment": "^2.22.1",
"node-fetch": "^1.7.1",
"node-persist": "^2.1.0",
"pako": "^1.0.6",
"pluralize": "^7.0.0",
"stream-json": "0.5.2",
"string-hash": "^1.1.3",
"string-to-stream": "^1.1.0",
"typescript-json-schema": "quicktype/typescript-json-schema#d16083d29c8b6702c666a981fa6b21113300c059",
"unicode-properties": "github:quicktype/unicode-properties#dist",
"universal-analytics": "^0.4.16",
"urijs": "^1.19.1",
"uuid": "^3.2.1"
},
"testRegex": "(/__tests__/.*)\\.test\\.(tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
}
"devDependencies": {
"@types/urijs": "github:quicktype/types-urijs",
"@types/string-hash": "^1.1.1",
"@types/is-url": "^1.2.28",
"@types/jest": "^22.2.0",
"@types/lodash": "^4.14.108",
"@types/node": "^8.10.10",
"@types/node-persist": "0.0.33",
"@types/shelljs": "^0.7.8",
"@types/universal-analytics": "^0.4.2",
"@types/semver": "^5.5.0",
"ajv": "^5.5.2",
"deep-equal": "^1.0.1",
"elm": "^0.18.0",
"exit": "^0.1.2",
"flow-bin": "^0.66.0",
"flow-remove-types": "^1.2.3",
"jest": "^22.4.3",
"pkg": "^4.3.1",
"promise-timeout": "^1.3.0",
"semver": "^5.5.0",
"shelljs": "^0.7.8",
"ts-jest": "^22.4.2",
"ts-node": "^3.3.0",
"tslint": "^5.9.1",
"typescript": "~2.8.3",
"uglify-js": "^3.3.22",
"watch": "^1.0.2",
"@types/graphql": "^0.11.7",
"@types/js-base64": "^2.3.1",
"@types/pako": "^1.0.0",
"@types/pluralize": "0.0.28"
},
"files": [
"dist/**"
],
"bin": "dist/cli/index.js",
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfigFile": "src/cli/tsconfig.json"
}
},
"testRegex": "(/__tests__/.*)\\.test\\.(tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}

Просмотреть файл

@ -2,7 +2,7 @@ import * as fs from "fs";
import * as path from "path";
import * as _ from "lodash";
import { Readable } from "stream";
import { hasOwnProperty, definedMap } from "collection-utils";
import { hasOwnProperty, definedMap, withDefault } from "collection-utils";
import {
Options,
@ -22,7 +22,6 @@ import {
panic,
assert,
defined,
withDefault,
assertNever,
parseJSON,
getStream,

Просмотреть файл

@ -1,8 +1,8 @@
import { arrayIntercalate, iterableMax } from "collection-utils";
import { arrayIntercalate, iterableMax, withDefault } from "collection-utils";
import { AnnotationData } from "./Annotation";
import { Name } from "./Naming";
import { defined, assertNever, panic, assert, withDefault } from "./support/Support";
import { defined, assertNever, panic, assert } from "./support/Support";
import { repeatString } from "./support/Strings";
export type Source =

Просмотреть файл

@ -5,11 +5,12 @@ import {
hashCodeOf,
areEqual,
mapMergeWithInto,
definedMap
definedMap,
addHashCode
} from "collection-utils";
import { TypeAttributeKind } from "./TypeAttributes";
import { addHashCode, defined, assert } from "./support/Support";
import { defined, assert } from "./support/Support";
import { StringTypeMapping } from "./TypeBuilder";
import { PrimitiveStringTypeKind } from "./Type";

Просмотреть файл

@ -1,9 +1,9 @@
import stringHash = require("string-hash");
import { setUnionInto, areEqual, hashCodeOf, definedMap } from "collection-utils";
import { setUnionInto, areEqual, hashCodeOf, definedMap, addHashCode } from "collection-utils";
import { UnionType, Type, EnumType, PrimitiveType } from "./Type";
import { TypeAttributeKind } from "./TypeAttributes";
import { panic, addHashCode, assert, indentationString } from "./support/Support";
import { panic, assert, indentationString } from "./support/Support";
import { BaseGraphRewriteBuilder } from "./GraphRewriting";
import { TypeRef, derefTypeRef, TypeGraph } from "./TypeGraph";

Просмотреть файл

@ -14,10 +14,12 @@ import {
setFilter,
setUnionInto,
mapSortToArray,
definedMap
definedMap,
hashCodeInit,
addHashCode
} from "collection-utils";
import { defined, panic, assert, hashCodeInit, addHashCode } from "./support/Support";
import { defined, panic, assert } from "./support/Support";
import { TypeReconstituter, BaseGraphRewriteBuilder } from "./GraphRewriting";
import { TypeNames, namesTypeAttributeKind } from "./TypeNames";
import { TypeAttributes } from "./TypeAttributes";

Просмотреть файл

@ -8,7 +8,8 @@ import {
setMap,
areEqual,
setUnionManyInto,
definedMap
definedMap,
withDefault
} from "collection-utils";
import {
@ -37,7 +38,7 @@ import {
import { removeNullFromUnion } from "./TypeUtils";
import { TypeGraph, TypeRef, makeTypeRef, derefTypeRef, typeRefIndex } from "./TypeGraph";
import { TypeAttributes, combineTypeAttributes, TypeAttributeKind, emptyTypeAttributes } from "./TypeAttributes";
import { defined, assert, panic, withDefault } from "./support/Support";
import { defined, assert, panic } from "./support/Support";
import { stringTypesTypeAttributeKind, StringTypes } from "./StringTypes";
// FIXME: Don't infer provenance. All original types should be present in

Просмотреть файл

@ -22,7 +22,6 @@ export {
panic,
assert,
defined,
withDefault,
assertNever,
parseJSON,
checkStringMap,

Просмотреть файл

@ -1,8 +1,9 @@
import * as stream from "stream";
import stringHash = require("string-hash");
import { addHashCode, hashCodeInit } from "collection-utils";
import { defined, hashCodeInit, addHashCode, panic, assert } from "../support/Support";
import { defined, panic, assert } from "../support/Support";
import { isDate, isTime, isDateTime } from "../DateTime";
const Combo = require("stream-json/Combo");

Просмотреть файл

@ -1,5 +1,5 @@
import * as URI from "urijs";
import { iterableFirst, iterableFind, iterableSome, setFilterMap } from "collection-utils";
import { iterableFirst, iterableFind, iterableSome, setFilterMap, withDefault } from "collection-utils";
import {
Ref,
@ -10,17 +10,7 @@ import {
} from "./JSONSchemaInput";
import { Value, CompressedJSON } from "./CompressedJSON";
import { JSONSchemaStore, JSONSchema } from "./JSONSchemaStore";
import {
parseJSON,
panic,
assert,
defined,
withDefault,
errorMessage,
toString,
toReadable,
StringInput
} from "../support/Support";
import { parseJSON, panic, assert, defined, errorMessage, toString, toReadable, StringInput } from "../support/Support";
import { messageError } from "../Messages";
import { TypeBuilder } from "../TypeBuilder";
import { makeNamesTypeAttributes } from "../TypeNames";

Просмотреть файл

@ -18,11 +18,12 @@ import {
arrayPop,
hashCodeOf,
hasOwnProperty,
definedMap
definedMap,
addHashCode
} from "collection-utils";
import { PrimitiveTypeKind } from "../Type";
import { panic, assertNever, StringMap, assert, defined, addHashCode } from "../support/Support";
import { panic, assertNever, StringMap, assert, defined } from "../support/Support";
import { TypeBuilder } from "../TypeBuilder";
import { TypeNames } from "../TypeNames";
import { makeNamesTypeAttributes, modifyTypeNames, singularizeTypeNames } from "../TypeNames";

Просмотреть файл

@ -1,5 +1,6 @@
import { iterableFind } from "collection-utils";
import { TargetLanguage } from "../TargetLanguage";
import { findInArray } from "../support/Support";
import { NewtonsoftCSharpTargetLanguage } from "./CSharp";
import { GoTargetLanguage } from "./Golang";
@ -36,7 +37,10 @@ export function languageNamed(name: string, targetLanguages?: TargetLanguage[]):
if (targetLanguages === undefined) {
targetLanguages = all;
}
const maybeTargetLanguage = findInArray(targetLanguages, l => l.names.indexOf(name) >= 0 || l.displayName === name);
const maybeTargetLanguage = iterableFind(
targetLanguages,
l => l.names.indexOf(name) >= 0 || l.displayName === name
);
if (maybeTargetLanguage !== undefined) return maybeTargetLanguage;
return findInArray(targetLanguages, l => l.extension === name);
return iterableFind(targetLanguages, l => l.extension === name);
}

Просмотреть файл

@ -6,13 +6,6 @@ import { messageError } from "../Messages";
const stringToStream = require("string-to-stream");
export function findInArray<T>(arr: T[], p: (t: T) => boolean): T | undefined {
for (const t of arr) {
if (p(t)) return t;
}
return undefined;
}
export type StringMap = { [name: string]: any };
export function isStringMap(x: any): x is StringMap;
@ -87,12 +80,6 @@ export function mustNotHappen(): never {
return panic("This must not happen");
}
export const hashCodeInit = 17;
export function addHashCode(acc: number, h: number): number {
return (acc * 31 + (h | 0)) | 0;
}
export function repeated<T>(n: number, value: T): T[] {
const arr: T[] = [];
for (let i = 0; i < n; i++) {
@ -109,13 +96,6 @@ export function repeatedCall<T>(n: number, producer: () => T): T[] {
return arr;
}
export function withDefault<T>(x: T | undefined, theDefault: T): T {
if (x !== undefined) {
return x;
}
return theDefault;
}
export function errorMessage(e: any): string {
if (e instanceof Error) {
return e.message;