-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.ts
191 lines (146 loc) · 4.33 KB
/
sandbox.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// tslint:disable:max-file-line-count
// // todo del this file
// class Docs {
// public static pages<PAGES extends object>(pagesObj: PAGES): PAGES {
// return pagesObj
// }
// }
// import {CODE_BLOCK}
// const CODE_BLOCK = Docs.insertions. // codeBlock, linkToArticle
// const pages = Docs.pages({
// "some section/category": section({
// "some page": {
// // ...
// },
// }),
// "foo bar": {
// "baz as": "qqq",
// },
// "some page": `some content here
// ${
// CODE_BLOCK(() => {
// const LINK = (title: keyof typeof pages) => {
// }
// LINK("some page") // deep-nested stuff is hard to access with keyof
// pages["foo bar"]["baz as"]
// // todo this means that pages must be proxy object
// })
// }
// `
// })
// pages
// .alias("alias name", "existing page title")
// .alias("alias name", "existing page title")
// const Some_page = `
// bar baz
// # Foo Bar
// ${codeBlock(() => {
// const some = {
// code: "here",
// }
// someFunc()
// new SomeClass()
// return some
// })}
// qqq
// `
// /**
// * QurDocs adds const value{n} or _value{n} (if value{n} name is already taken)
// * or __value{n} (if __value{n} name is already taken) etc.
// * before someFunc() and new SomeClass(),
// * or maybe those tmp variables value{n} are not required
// * executes script
// * and gets values of said expressions.
// * That values as well as value of "const some"
// * are written to test case
// * e.g:
// */
// /**
// * value1 holds value of following expression:
// * {
// code: "here",
// }
// */
// expect(stringify(value1)).to.equal(stringify({
// code: "here"
// })) // stringify only if object
// /**
// * value2 holds value of following expression:
// * someFunc()
// */
// expect(value2).to.equal(...) // no stringify, because not object (we suppose someFunc() returns not object)
// /**
// * value3 holds value of following expression:
// * new SomeClass()
// */
// expect(value3).to.equal(...)
// /**
// *
// */
// if (0) {
// type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
// const array = [{ foo: 'val1' }, { bar: 'val2' }]
// function flatten<T>(array: T[]): T {
// // implementation here, does not matter, all that matter is that it returns following:
// return { foo: 'val1', bar: 'val2' } as any
// }
// // at this point IDE suggests two values: "foo" and "bar"
// console.log(flatten(array)) // TODO DELETE
// }
// else {
// const section: {
// <TITLE extends string = "_none_">(content: string): TSection<TITLE>;
// // tslint:disable:unified-signatures
// <TITLE extends string>(title: TITLE, content: string): TSection<TITLE>;
// } = (first: string, second?: string) => {
// let title: string
// let content: string
// if (second) {
// title = first
// content = second
// } else {
// title = "_none_"
// content = first
// }
// return {
// [title]: content,
// }
// }
// type TSection<TITLE extends string = string> = {
// [K in TITLE]: string
// }
// // T = TSection ({foo: 'val'})
// // tslint:disable
// const page = <T>(sections: T[]): T => {
// // console.log(sections) // TODO DELETE
// return { foo: 'val1', bar: 'val2' } as any
// }
// const array = [{ foo: 'val1' }, { bar: 'val2' }]
// // const thepage = page(section(`content 1`), section("some title", `content 2`), section("fo"))
// const thepage = page([
// section("some title", "hgfhg"),
// section("some title 2", `test content`)
// ]
// ).
// // console.log(thepage.) // TODO DELETE
// }
// TRANSLATIONS (low pr):
// interface ITemplate {
// foo: string
// }
// const original = {
// foo: {
// bar: "baz",
// },
// qqq: {
// eee: {
// "some title": 111,
// },
// 222: {
// "uuu aaa": 222,
// },
// },
// }
// function translate<TEMPLATE>(lang: string, trans: TEMPLATE): void {
// // todo
// }