source: node_modules/stampit/types/index.d.ts

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 28.2 KB
Line 
1// Type definitions for stampit 4.3
2// Project: https://github.com/stampit-org/stampit, https://stampit.js.org
3// Definitions by: Vasyl Boroviak <https://github.com/koresar>
4// Harris Lummis <https://github.com/lummish>
5// PopGoesTheWza <https://github.com/popgoesthewza>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// TypeScript Version: 3.5
8
9// Utility types
10
11/**
12 * @internal Base type for all `methods`-like metadata.
13 * @template This The type to use for `this` within methods.
14 */
15interface MethodMap<This> {
16 [s: string]: ((this: This, ...args: any[]) => any) | {};
17}
18
19/** @internal A plain old JavaScript object created by a `Stamp`. */
20type Pojo = object; // { [s: string]: any; }
21
22/** @internal Base type for all `properties`-like metadata. */
23// TODO: discriminate Array
24type PropertyMap = object; // { [s: string]: any; }
25
26/** @internal Signature common to every `Stamp`s. */
27interface StampSignature {
28 (options?: PropertyMap, ...args: unknown[]): any;
29 compose: ComposeMethod & stampit.Descriptor<any, any>;
30}
31
32/**
33* @internal Extracts the `Stamp` type.
34* @template Original The type to extract the `Stamp` type from.
35*/
36type StampType<Original> = Original extends /* disallowed types */ [] | bigint
37 ? never
38 : stampit.IsADescriptor<Original> extends true
39 ? (Original extends stampit.ExtendedDescriptor<infer Obj, infer Stamp> ? Stamp : never)
40 : unknown extends Original /* is any or unknown */
41 ? stampit.Stamp<Original>
42 : Original extends StampSignature
43 ? Original
44 : Original extends stampit.ExtendedDescriptor<infer Obj, any>
45 ? stampit.Stamp<Obj>
46 : Original extends Pojo
47 ? stampit.Stamp<Original> /*assume it is the object from a stamp object*/
48 : never;
49
50/**
51* @internal The type of the object produced by the `Stamp`.
52* @template Original The type (either a `Stamp` or a `ExtendedDescriptor`) to get the object type from.
53*/
54type StampObjectType<Original> = Original extends /* disallowed types */ bigint | boolean | number | string | symbol
55 ? never
56 : stampit.IsADescriptor<Original> extends true
57 ? (Original extends stampit.ExtendedDescriptor<infer Obj, any> ? Obj : never)
58 : unknown extends Original /* is any or unknown */
59 ? Original
60 : Original extends StampSignature
61 ? (Original extends stampit.Stamp<infer Obj> /* extended stamps may require infering twice */
62 ? (Obj extends stampit.Stamp<infer Obj> ? Obj : Obj)
63 : any)
64 : Original extends stampit.ExtendedDescriptor<infer Obj, any>
65 ? Obj
66 : Original extends Pojo
67 ? Original
68 : never;
69
70/**
71* A factory function to create plain object instances.
72* @template Obj The object type that the `Stamp` will create.
73*/
74interface FactoryFunction<Obj> {
75 (options?: PropertyMap, ...args: any[]): StampObjectType<Obj>;
76}
77
78/**
79* @internal Chainables `Stamp` additionnal methods
80* @template Obj The object type that the `Stamp` will create.
81*/
82type StampChainables<Obj> = Chainables<StampObjectType<Obj>, StampType<Obj>>;
83
84/**
85* @internal Chainables `Stamp` additionnal methods
86* @template Obj The object type that the `Stamp` will create.
87* @template S̤t̤a̤m̤p̤ The type of the `Stamp` (when extending a `Stamp`.)
88*/
89interface Chainables<Obj, S̤t̤a̤m̤p̤ extends StampSignature> {
90 /**
91 * Add methods to the methods prototype. Creates and returns new Stamp. **Chainable**.
92 * @template This The type to use for `this` within methods.
93 * @param methods Object(s) containing map of method names and bodies for delegation.
94 */
95 // tslint:disable-next-line: no-unnecessary-generics
96 methods<This = Obj>(...methods: Array<MethodMap<This>>): S̤t̤a̤m̤p̤;
97
98 /**
99 * Take a variable number of objects and shallow assign them to any future created instance of the Stamp. Creates and returns new Stamp. **Chainable**.
100 * @param objects Object(s) to shallow assign for each new object.
101 */
102 properties(...objects: PropertyMap[]): S̤t̤a̤m̤p̤;
103
104 /**
105 * Take a variable number of objects and shallow assign them to any future created instance of the Stamp. Creates and returns new Stamp. **Chainable**.
106 * @param objects Object(s) to shallow assign for each new object.
107 */
108 props(...objects: PropertyMap[]): S̤t̤a̤m̤p̤;
109
110 /**
111 * Take a variable number of objects and deeply merge them to any future created instance of the Stamp. Creates and returns a new Stamp. **Chainable**.
112 * @param deepObjects The object(s) to deeply merge for each new object.
113 */
114 deepProperties(...deepObjects: PropertyMap[]): S̤t̤a̤m̤p̤;
115
116 /**
117 * Take a variable number of objects and deeply merge them to any future created instance of the Stamp. Creates and returns a new Stamp. **Chainable**.
118 * @param deepObjects The object(s) to deeply merge for each new object.
119 */
120 deepProps(...deepObjects: PropertyMap[]): S̤t̤a̤m̤p̤;
121
122 /**
123 * Take in a variable number of functions and add them to the initializers prototype as initializers. **Chainable**.
124 * @param functions Initializer functions used to create private data and privileged methods.
125 */
126 initializers(...functions: Array<stampit.Initializer<Obj, S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
127 initializers(functions: Array<stampit.Initializer<Obj, S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
128
129 /**
130 * Take in a variable number of functions and add them to the initializers prototype as initializers. **Chainable**.
131 * @param functions Initializer functions used to create private data and privileged methods.
132 */
133 init(...functions: Array<stampit.Initializer<Obj, S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
134 init(functions: Array<stampit.Initializer<Obj, S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
135
136 /**
137 * Take n objects and add them to a new stamp and any future stamp it composes with. Creates and returns new Stamp. **Chainable**.
138 * @param statics Object(s) containing map of property names and values to mixin into each new stamp.
139 */
140 staticProperties(...statics: PropertyMap[]): S̤t̤a̤m̤p̤;
141
142 /**
143 * Take n objects and add them to a new stamp and any future stamp it composes with. Creates and returns new Stamp. **Chainable**.
144 * @param statics Object(s) containing map of property names and values to mixin into each new stamp.
145 */
146 statics(...statics: PropertyMap[]): S̤t̤a̤m̤p̤;
147
148 /**
149 * Deeply merge a variable number of objects and add them to a new stamp and any future stamp it composes. Creates and returns a new Stamp. **Chainable**.
150 * @param deepStatics The object(s) containing static properties to be merged.
151 */
152 staticDeepProperties(...deepStatics: PropertyMap[]): S̤t̤a̤m̤p̤;
153
154 /**
155 * Deeply merge a variable number of objects and add them to a new stamp and any future stamp it composes. Creates and returns a new Stamp. **Chainable**.
156 * @param deepStatics The object(s) containing static properties to be merged.
157 */
158 deepStatics(...deepStatics: PropertyMap[]): S̤t̤a̤m̤p̤;
159
160 /**
161 * Take in a variable number of functions and add them to the composers prototype as composers. **Chainable**.
162 * @param functions Composer functions that will run in sequence while creating a new stamp from a list of composables. The resulting stamp and the composables get passed to composers.
163 */
164 composers(...functions: Array<stampit.Composer<S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
165 composers(functions: Array<stampit.Composer<S̤t̤a̤m̤p̤>>): S̤t̤a̤m̤p̤;
166
167 /**
168 * Shallowly assign properties of Stamp arbitrary metadata and add them to a new stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
169 * @param confs The object(s) containing metadata properties.
170 */
171 configuration(...confs: PropertyMap[]): S̤t̤a̤m̤p̤;
172
173 /**
174 * Shallowly assign properties of Stamp arbitrary metadata and add them to a new stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
175 * @param confs The object(s) containing metadata properties.
176 */
177 conf(...confs: PropertyMap[]): S̤t̤a̤m̤p̤;
178
179 /**
180 * Deeply merge properties of Stamp arbitrary metadata and add them to a new Stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
181 * @param deepConfs The object(s) containing metadata properties.
182 */
183 deepConfiguration(...deepConfs: PropertyMap[]): S̤t̤a̤m̤p̤;
184
185 /**
186 * Deeply merge properties of Stamp arbitrary metadata and add them to a new Stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
187 * @param deepConfs The object(s) containing metadata properties.
188 */
189 deepConf(...deepConfs: PropertyMap[]): S̤t̤a̤m̤p̤;
190
191 /**
192 * Apply ES5 property descriptors to object instances created by the new Stamp returned by the function and any future Stamp it composes. Creates and returns a new stamp. **Chainable**.
193 * @param descriptors
194 */
195 propertyDescriptors(...descriptors: PropertyDescriptorMap[]): S̤t̤a̤m̤p̤;
196
197 /**
198 * Apply ES5 property descriptors to a Stamp and any future Stamp it composes. Creates and returns a new stamp. **Chainable**.
199 * @param descriptors
200 */
201 staticPropertyDescriptors(...descriptors: PropertyDescriptorMap[]): S̤t̤a̤m̤p̤;
202}
203
204/**
205* A function which creates a new `Stamp`s from a list of `Composable`s.
206* @template Obj The type of the object instance being produced by the `Stamp` or the type of the `Stamp` being created (when extending a `Stamp`.)
207*/
208type ComposeMethod = typeof stampit;
209
210/**
211* A function which creates a new `Stamp`s from a list of `Composable`s.
212* @template Obj The type of the object instance being created by the `Stamp` or the type of the `Stamp` being created (when extending a `Stamp`.)
213*/
214// tslint:disable-next-line: no-unnecessary-generics
215declare function stampit<Obj = any>(...composables: stampit.Composable[]): StampType<Obj>;
216
217declare namespace stampit {
218 /** A composable object (either a `Stamp` or a `ExtendedDescriptor`.) */
219 type Composable = StampSignature | ExtendedDescriptor<any, any>;
220
221 /**
222 * A `Stamp`'s metadata.
223 * @template Obj The type of the object instance being produced by the `Stamp`.
224 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` (when extending a `Stamp`.)
225 */
226 interface Descriptor<Obj, S̤t̤a̤m̤p̤ extends StampSignature = Stamp<Obj>> {
227 /** A set of methods that will be added to the object's delegate prototype. */
228 methods?: MethodMap<Obj>;
229 /** A set of properties that will be added to new object instances by assignment. */
230 properties?: PropertyMap;
231 /** A set of properties that will be added to new object instances by deep property merge. */
232 deepProperties?: PropertyMap;
233 /** A set of object property descriptors (`PropertyDescriptor`) used for fine-grained control over object property behaviors. */
234 propertyDescriptors?: PropertyDescriptorMap;
235 /** A set of static properties that will be copied by assignment to the `Stamp`. */
236 staticProperties?: PropertyMap;
237 /** A set of static properties that will be added to the `Stamp` by deep property merge. */
238 staticDeepProperties?: PropertyMap;
239 /** A set of object property descriptors (`PropertyDescriptor`) to apply to the `Stamp`. */
240 staticPropertyDescriptors?: PropertyDescriptorMap;
241 /** An array of functions that will run in sequence while creating an object instance from a `Stamp`. `Stamp` details and arguments get passed to initializers. */
242 initializers?: Initializer<Obj, S̤t̤a̤m̤p̤> | Array<Initializer<Obj, S̤t̤a̤m̤p̤>>;
243 /** An array of functions that will run in sequence while creating a new `Stamp` from a list of `Composable`s. The resulting `Stamp` and the `Composable`s get passed to composers. */
244 composers?: Array<Composer<S̤t̤a̤m̤p̤>>;
245 /** A set of options made available to the `Stamp` and its initializers during object instance creation. These will be copied by assignment. */
246 configuration?: PropertyMap;
247 /** A set of options made available to the `Stamp` and its initializers during object instance creation. These will be deep merged. */
248 deepConfiguration?: PropertyMap;
249 }
250
251 /**
252 * A `stampit`'s metadata.
253 * @template Obj The type of the object instance being produced by the `Stamp`.
254 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` (when extending a `Stamp`.)
255 */
256 interface ExtendedDescriptor<Obj, S̤t̤a̤m̤p̤ extends StampSignature = Stamp<Obj>> extends Descriptor<Obj, S̤t̤a̤m̤p̤> {
257 /** A set of properties that will be added to new object instances by assignment. */
258 props?: PropertyMap;
259 /** A set of properties that will be added to new object instances by deep property merge. */
260 deepProps?: PropertyMap;
261 /** A set of static properties that will be copied by assignment to the `Stamp`. */
262 statics?: PropertyMap;
263 /** A set of static properties that will be added to the `Stamp` by deep property merge. */
264 deepStatics?: PropertyMap;
265 /** An array of functions that will run in sequence while creating an object instance from a `Stamp`. `Stamp` details and arguments get passed to initializers. */
266 init?: Initializer<Obj, S̤t̤a̤m̤p̤> | Array<Initializer<Obj, S̤t̤a̤m̤p̤>>;
267 /** A set of options made available to the `Stamp` and its initializers during object instance creation. These will be copied by assignment. */
268 conf?: PropertyMap;
269 /** A set of options made available to the `Stamp` and its initializers during object instance creation. These will be deep merged. */
270 deepConf?: PropertyMap;
271 // TODO: Add description
272 name?: string;
273 }
274
275 /**
276 * @internal Checks that a type is a ExtendedDescriptor (except `any` and `unknown`).
277 * @template Type A type to check if a ExtendedDescriptor.
278 */
279 // TODO: Improve test by checking the type of common keys
280 type IsADescriptor<Type> = unknown extends Type
281 ? (keyof Type extends never
282 ? false
283 : keyof Type extends infer K
284 ? (K extends keyof ExtendedDescriptor<unknown> ? true : false)
285 : false)
286 : false;
287
288 /**
289 * A function used as `.initializers` argument.
290 * @template Obj The type of the object instance being produced by the `Stamp`.
291 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` producing the instance.
292 */
293 interface Initializer<Obj, S̤t̤a̤m̤p̤ extends StampSignature> {
294 (this: Obj, options: /*_propertyMap*/ any, context: InitializerContext<Obj, S̤t̤a̤m̤p̤>): void | Obj;
295 }
296
297 /**
298 * The `Initializer` function context.
299 * @template Obj The type of the object instance being produced by the `Stamp`.
300 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` producing the instance.
301 */
302 interface InitializerContext<Obj, S̤t̤a̤m̤p̤ extends StampSignature> {
303 /** The object instance being produced by the `Stamp`. If the initializer returns a value other than `undefined`, it replaces the instance. */
304 instance: Obj;
305 /** A reference to the `Stamp` producing the instance. */
306 stamp: S̤t̤a̤m̤p̤;
307 /** An array of the arguments passed into the `Stamp`, including the options argument. */
308 // ! above description from the specification is obscure
309 args: any[];
310 }
311
312 /**
313 * A function used as `.composers` argument.
314 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` produced by the `.compose()` method.
315 */
316 interface Composer<S̤t̤a̤m̤p̤ extends StampSignature> {
317 (parameters: ComposerParameters<S̤t̤a̤m̤p̤>): void | S̤t̤a̤m̤p̤ ;
318 }
319
320 /**
321 * The parameters received by the current `.composers` function.
322 * @template S̤t̤a̤m̤p̤ The type of the `Stamp` produced by the `.compose()` method.
323 */
324 interface ComposerParameters<S̤t̤a̤m̤p̤ extends StampSignature> {
325 /** The result of the `Composable`s composition. */
326 stamp: S̤t̤a̤m̤p̤;
327 /** The list of composables the `Stamp` was just composed of. */
328 composables: Composable[];
329 }
330
331 /**
332 * A factory function to create plain object instances.
333 *
334 * It also has a `.compose()` method which is a copy of the `ComposeMethod` function and a `.compose` accessor to its `Descriptor`.
335 * @template Obj The object type that the `Stamp` will create.
336 */
337 interface Stamp<Obj> extends FactoryFunction<Obj>, StampChainables<Obj>, StampSignature {
338 /** Just like calling stamp(), stamp.create() invokes the stamp and returns a new instance. */
339 create: FactoryFunction<Obj>;
340
341 /**
342 * A function which creates a new `Stamp`s from a list of `Composable`s.
343 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
344 */
345 compose: ComposeMethod & Descriptor<StampObjectType<Obj>>;
346 }
347
348 /**
349 * A shortcut method for stampit().methods()
350 *
351 * Add methods to the methods prototype. Creates and returns new Stamp. **Chainable**.
352 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
353 * @template This The type to use for `this` within methods.
354 * @param methods Object(s) containing map of method names and bodies for delegation.
355 */
356 function methods<Obj = any>(this: StampObjectType<Obj>, ...methods: Array<MethodMap<Obj>>): StampType<Obj>;
357
358 /**
359 * A shortcut method for stampit().properties()
360 *
361 * Take a variable number of objects and shallow assign them to any future created instance of the Stamp. Creates and returns new Stamp. **Chainable**.
362 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
363 * @param objects Object(s) to shallow assign for each new object.
364 */
365 // tslint:disable-next-line: no-unnecessary-generics
366 function properties<Obj = any>(...objects: PropertyMap[]): StampType<Obj>;
367
368 /**
369 * A shortcut method for stampit().props()
370 *
371 * Take a variable number of objects and shallow assign them to any future created instance of the Stamp. Creates and returns new Stamp. **Chainable**.
372 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
373 * @param objects Object(s) to shallow assign for each new object.
374 */
375 // tslint:disable-next-line: no-unnecessary-generics
376 function props<Obj = any>(...objects: PropertyMap[]): StampType<Obj>;
377
378 /**
379 * A shortcut method for stampit().deepProperties()
380 *
381 * Take a variable number of objects and deeply merge them to any future created instance of the Stamp. Creates and returns a new Stamp.
382 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
383 * @param deepObjects The object(s) to deeply merge for each new object
384 */
385 // tslint:disable-next-line: no-unnecessary-generics
386 function deepProperties<Obj = any>(...deepObjects: PropertyMap[]): StampType<Obj>;
387
388 /**
389 * A shortcut method for stampit().deepProps()
390 *
391 * Take a variable number of objects and deeply merge them to any future created instance of the Stamp. Creates and returns a new Stamp.
392 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
393 * @param deepObjects The object(s) to deeply merge for each new object
394 */
395 // tslint:disable-next-line: no-unnecessary-generics
396 function deepProps<Obj = any>(...deepObjects: PropertyMap[]): StampType<Obj>;
397
398 /**
399 * A shortcut method for stampit().initializers()
400 *
401 * Take in a variable number of functions and add them to the initializers prototype as initializers. **Chainable**.
402 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
403 * @param functions Initializer functions used to create private data and privileged methods
404 */
405 function initializers<Obj = any, S̤t̤a̤m̤p̤ extends StampSignature = StampType<Obj>>(
406 // tslint:disable-next-line: no-unnecessary-generics
407 ...functions: Array<Initializer<StampObjectType<Obj>, S̤t̤a̤m̤p̤>>
408 ): S̤t̤a̤m̤p̤;
409 function initializers<Obj = any, S̤t̤a̤m̤p̤ extends StampSignature = StampType<Obj>>(
410 // tslint:disable-next-line: no-unnecessary-generics
411 functions: Array<Initializer<StampObjectType<Obj>, S̤t̤a̤m̤p̤>>,
412 ): S̤t̤a̤m̤p̤;
413
414 /**
415 * A shortcut method for stampit().init()
416 *
417 * Take in a variable number of functions and add them to the initializers prototype as initializers. **Chainable**.
418 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
419 * @param functions Initializer functions used to create private data and privileged methods
420 */
421 function init<Obj = any, S̤t̤a̤m̤p̤ extends StampSignature = StampType<Obj>>(
422 // tslint:disable-next-line: no-unnecessary-generics
423 ...functions: Array<Initializer<StampObjectType<Obj>, S̤t̤a̤m̤p̤>>
424 ): S̤t̤a̤m̤p̤;
425 function init<Obj = any, S̤t̤a̤m̤p̤ extends StampSignature = StampType<Obj>>(
426 // tslint:disable-next-line: no-unnecessary-generics
427 functions: Array<Initializer<StampObjectType<Obj>, S̤t̤a̤m̤p̤>>,
428 ): S̤t̤a̤m̤p̤;
429
430 /**
431 * A shortcut method for stampit().statics()
432 *
433 * Take n objects and add them to a new stamp and any future stamp it composes with. Creates and returns new Stamp. **Chainable**.
434 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
435 * @param statics Object(s) containing map of property names and values to mixin into each new stamp.
436 */
437 // tslint:disable-next-line: no-unnecessary-generics
438 function staticProperties<Obj = any>(...statics: PropertyMap[]): StampType<Obj>;
439
440 /**
441 * A shortcut method for stampit().staticProperties()
442 *
443 * Take n objects and add them to a new stamp and any future stamp it composes with. Creates and returns new Stamp. **Chainable**.
444 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
445 * @param statics Object(s) containing map of property names and values to mixin into each new stamp.
446 */
447 // tslint:disable-next-line: no-unnecessary-generics
448 function statics<Obj = any>(...statics: PropertyMap[]): StampType<Obj>;
449
450 /**
451 * A shortcut method for stampit().staticDeepProperties()
452 *
453 * Deeply merge a variable number of objects and add them to a new stamp and any future stamp it composes. Creates and returns a new Stamp. **Chainable**.
454 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
455 * @param deepStatics The object(s) containing static properties to be merged
456 */
457 // tslint:disable-next-line: no-unnecessary-generics
458 function staticDeepProperties<Obj = any>(...deepStatics: PropertyMap[]): StampType<Obj>;
459
460 /**
461 * A shortcut method for stampit().deepStatics()
462 *
463 * Deeply merge a variable number of objects and add them to a new stamp and any future stamp it composes. Creates and returns a new Stamp. **Chainable**.
464 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
465 * @param deepStatics The object(s) containing static properties to be merged
466 */
467 // tslint:disable-next-line: no-unnecessary-generics
468 function deepStatics<Obj = any>(...deepStatics: PropertyMap[]): StampType<Obj>;
469
470 /**
471 * A shortcut method for stampit().composers()
472 *
473 * Take in a variable number of functions and add them to the composers prototype as composers. **Chainable**.
474 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
475 * @param functions Composer functions that will run in sequence while creating a new stamp from a list of composables. The resulting stamp and the composables get passed to composers.
476 */
477 function composers<Obj = any>(...functions: Array<Composer<StampType<Obj>>>): StampType<Obj>;
478 function composers<Obj = any>(functions: Array<Composer<StampType<Obj>>>): StampType<Obj>;
479
480 /**
481 * A shortcut method for stampit().configuration()
482 *
483 * Shallowly assign properties of Stamp arbitrary metadata and add them to a new stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
484 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
485 * @param confs The object(s) containing metadata properties
486 */
487 // tslint:disable-next-line: no-unnecessary-generics
488 function configuration<Obj = any>(...confs: PropertyMap[]): StampType<Obj>;
489
490 /**
491 * A shortcut method for stampit().conf()
492 *
493 * Shallowly assign properties of Stamp arbitrary metadata and add them to a new stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
494 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
495 * @param confs The object(s) containing metadata properties
496 */
497 // tslint:disable-next-line: no-unnecessary-generics
498 function conf<Obj = any>(...confs: PropertyMap[]): StampType<Obj>;
499
500 /**
501 * A shortcut method for stampit().deepConfiguration()
502 *
503 * Deeply merge properties of Stamp arbitrary metadata and add them to a new Stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
504 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
505 * @param deepConfs The object(s) containing metadata properties
506 */
507 // tslint:disable-next-line: no-unnecessary-generics
508 function deepConfiguration<Obj = any>(...deepConfs: PropertyMap[]): StampType<Obj>;
509
510 /**
511 * A shortcut method for stampit().deepConf()
512 *
513 * Deeply merge properties of Stamp arbitrary metadata and add them to a new Stamp and any future Stamp it composes. Creates and returns a new Stamp. **Chainable**.
514 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
515 * @param deepConfs The object(s) containing metadata properties
516 */
517 // tslint:disable-next-line: no-unnecessary-generics
518 function deepConf<Obj = any>(...deepConfs: PropertyMap[]): StampType<Obj>;
519
520 /**
521 * A shortcut method for stampit().propertyDescriptors()
522 *
523 * Apply ES5 property descriptors to object instances created by the new Stamp returned by the function and any future Stamp it composes. Creates and returns a new stamp. **Chainable**.
524 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
525 * @param descriptors
526 */
527 // tslint:disable-next-line: no-unnecessary-generics
528 function propertyDescriptors<Obj = any>(...descriptors: PropertyDescriptorMap[]): StampType<Obj>;
529
530 /**
531 * A shortcut method for stampit().staticPropertyDescriptors()
532 *
533 * Apply ES5 property descriptors to a Stamp and any future Stamp it composes. Creates and returns a new stamp. **Chainable**.
534 * @template Obj The type of the object instance being produced by the `Stamp`. or the type of the `Stamp` being created.
535 * @param descriptors
536 */
537 // tslint:disable-next-line: no-unnecessary-generics
538 function staticPropertyDescriptors<Obj = any>(...descriptors: PropertyDescriptorMap[]): StampType<Obj>;
539
540 /** A function which creates a new `Stamp`s from a list of `Composable`s. */
541 const compose: ComposeMethod;
542
543 /** the version of the NPM `stampit` package. */
544 const version: string;
545}
546export const compose: typeof stampit.compose;
547export const composers: typeof stampit.composers;
548export const conf: typeof stampit.conf;
549export const configuration: typeof stampit.configuration;
550export const deepConf: typeof stampit.deepConf;
551export const deepConfiguration: typeof stampit.deepConfiguration;
552export const deepProperties: typeof stampit.deepProperties;
553export const deepProps: typeof stampit.deepProps;
554export const deepStatics: typeof stampit.deepStatics;
555export const init: typeof stampit.init;
556export const initializers: typeof stampit.initializers;
557export const methods: typeof stampit.methods;
558export const properties: typeof stampit.properties;
559export const propertyDescriptors: typeof stampit.propertyDescriptors;
560export const props: typeof stampit.props;
561export const staticDeepProperties: typeof stampit.staticDeepProperties;
562export const staticProperties: typeof stampit.staticProperties;
563export const staticPropertyDescriptors: typeof stampit.staticPropertyDescriptors;
564export const version: typeof stampit.version;
565// tslint:disable-next-line: npm-naming
566export default stampit;
Note: See TracBrowser for help on using the repository browser.