1 | import { Dict, Nullable, Stack, SimpleElement, SimpleNode } from "@glimmer/interfaces";
|
2 | declare const EMPTY_ARRAY: readonly unknown[];
|
3 | declare function emptyArray<T>(): T[];
|
4 | declare const EMPTY_STRING_ARRAY: string[];
|
5 | declare const EMPTY_NUMBER_ARRAY: number[];
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | declare function isEmptyArray(input: unknown[] | readonly unknown[]): boolean;
|
11 | declare function reverse<T>(input: T[]): IterableIterator<T>;
|
12 | declare function enumerate<T>(input: Iterable<T>): IterableIterator<[
|
13 | number,
|
14 | T
|
15 | ]>;
|
16 | type ZipEntry<T extends readonly unknown[]> = {
|
17 | [P in keyof T]: P extends `${infer N extends number}` ? [
|
18 | N,
|
19 | T[P],
|
20 | T[P]
|
21 | ] : never;
|
22 | }[keyof T & number];
|
23 |
|
24 |
|
25 |
|
26 | declare function zipTuples<T extends readonly unknown[]>(left: T, right: T): IterableIterator<ZipEntry<T>>;
|
27 | declare function zipArrays<T>(left: T[], right: T[]): IterableIterator<[
|
28 | "retain",
|
29 | number,
|
30 | T,
|
31 | T
|
32 | ] | [
|
33 | "pop",
|
34 | number,
|
35 | T,
|
36 | undefined
|
37 | ] | [
|
38 | "push",
|
39 | number,
|
40 | undefined,
|
41 | T
|
42 | ]>;
|
43 | declare function dict<T = unknown>(): Dict<T>;
|
44 | declare function isDict<T>(u: T): u is Dict & T;
|
45 | declare function isIndexable<T>(u: T): u is object & T;
|
46 | declare class StackImpl<T> implements Stack<T> {
|
47 | private stack;
|
48 | current: Nullable<T>;
|
49 | constructor(values?: T[]);
|
50 | get size(): number;
|
51 | push(item: T): void;
|
52 | pop(): Nullable<T>;
|
53 | nth(from: number): Nullable<T>;
|
54 | isEmpty(): boolean;
|
55 | snapshot(): T[];
|
56 | toArray(): T[];
|
57 | }
|
58 | declare let beginTestSteps: (() => void) | undefined;
|
59 | declare let endTestSteps: (() => void) | undefined;
|
60 | declare let verifySteps: ((type: string, steps: unknown[] | ((steps: unknown[]) => void), message?: string) => void) | undefined;
|
61 | declare let logStep: ((type: string, steps: unknown) => void) | undefined;
|
62 | declare function clearElement(parent: SimpleElement): void;
|
63 | /**
|
64 | Strongly hint runtimes to intern the provided string.
|
65 |
|
66 | When do I need to use this function?
|
67 |
|
68 | For the most part, never. Pre-mature optimization is bad, and often the
|
69 | runtime does exactly what you need it to, and more often the trade-off isn't
|
70 | worth it.
|
71 |
|
72 | Why?
|
73 |
|
74 | Runtimes store strings in at least 2 different representations:
|
75 | Ropes and Symbols (interned strings). The Rope provides a memory efficient
|
76 | data-structure for strings created from concatenation or some other string
|
77 | manipulation like splitting.
|
78 |
|
79 | Unfortunately checking equality of different ropes can be quite costly as
|
80 | runtimes must resort to clever string comparison algorithms. These
|
81 | algorithms typically cost in proportion to the length of the string.
|
82 | Luckily, this is where the Symbols (interned strings) shine. As Symbols are
|
83 | unique by their string content, equality checks can be done by pointer
|
84 | comparison.
|
85 |
|
86 | How do I know if my string is a rope or symbol?
|
87 |
|
88 | Typically (warning general sweeping statement, but truthy in runtimes at
|
89 | present) static strings created as part of the JS source are interned.
|
90 | Strings often used for comparisons can be interned at runtime if some
|
91 | criteria are met. One of these criteria can be the size of the entire rope.
|
92 | For example, in chrome 38 a rope longer then 12 characters will not
|
93 | intern, nor will segments of that rope.
|
94 |
|
95 | Some numbers: http://jsperf.com/eval-vs-keys/8
|
96 |
|
97 | Known Trick™
|
98 |
|
99 | @private
|
100 | @return {String} interned version of the provided string
|
101 | */
|
102 | declare function intern(str: string): string;
|
103 | declare const SERIALIZATION_FIRST_NODE_STRING = "%+b:0%";
|
104 | declare function isSerializationFirstNode(node: SimpleNode): boolean;
|
105 | declare let assign: {
|
106 | <T extends {}, U>(target: T, source: U): T & U;
|
107 | <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
108 | <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
109 | (target: object, ...sources: any[]): any;
|
110 | };
|
111 | declare function values<T>(obj: {
|
112 | [s: string]: T;
|
113 | }): T[];
|
114 | type ObjectEntry<D extends object> = {
|
115 | [P in keyof D]: [
|
116 | P,
|
117 | D[P]
|
118 | ];
|
119 | }[keyof D];
|
120 | declare function entries<D extends object>(dict: D): ObjectEntry<D>[];
|
121 | declare function keys<T extends object>(obj: T): (keyof T)[];
|
122 | declare function strip(strings: TemplateStringsArray, ...args: unknown[]): string;
|
123 | type FIXME<T, S extends string> = (T & S) | T;
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | declare const LOCAL_LOGGER: Console;
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | declare const LOGGER: Console;
|
140 | declare function assertNever(value: never, desc?: string): never;
|
141 | export { EMPTY_ARRAY, emptyArray, EMPTY_STRING_ARRAY, EMPTY_NUMBER_ARRAY, isEmptyArray, reverse, enumerate, zipTuples, zipArrays, dict, isDict, isIndexable, StackImpl as Stack, beginTestSteps, endTestSteps, logStep, verifySteps, clearElement, intern, isSerializationFirstNode, SERIALIZATION_FIRST_NODE_STRING, assign, entries, keys, values, strip, FIXME, LOCAL_LOGGER, LOGGER, assertNever };
|
142 |
|
\ | No newline at end of file |