This repository has been archived by the owner on Feb 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoru.js
120 lines (106 loc) · 2.71 KB
/
yoru.js
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
//
// 夜.js
//
require('babel-core/register');
require('babel-polyfill');
require('@webcomponents/webcomponentsjs/webcomponents-lite');
import Handlebars from 'handlebars';
import { readonly } from 'core-decorators';
import YoruObject from 'yoru/object';
import YoruApp from 'yoru/app';
import { YoruArray } from 'yoru/extensions';
import { Logger, Scribe, Run } from 'yoru/utils';
/**
* Yoru namespace
*
* Exposes the Yoru public API
*/
class Yoru extends YoruObject {
/**
* Handlebars
*
* A reference to the Handlebars templating library
*/
@readonly
static Handlebars = Handlebars;
/**
* YoruObject
*
* A reference to the Yoru native object.
* This can be used directly as a constructor, or can be extended as needed.
*/
@readonly
static Object = YoruObject;
/**
* YoruApp
*
* The Yoru application runtime.
*/
@readonly
static App = YoruApp;
/**
* Logger
*
* The Yoru builtin logger. This is a namespace, not a constructor.
* Exposes methods such as `log`, `debug` or `error`,
* plus a helper function to print styled text to the console, with feature
* detection.
*/
@readonly
static Logger = Logger;
/**
* Scribe
*
* A collection of string formatting functions. This is a namespace, not a
* constructor.
* Exposes methods such as `camelize`, `dasherize` or `constantize`.
*/
@readonly
static Scribe = Scribe;
/**
* Run
*
* A collection of run loop related functions. This is a namespace, not a
* constructor.
* Exposes functions such as `later`, `async` or `cancel`.
*/
@readonly
static Run = Run;
/**
* Array
*
* The YoruArray class. Extends the native JavaScript array class. Can be
* built from a native array using the `Yoru.A` function.
* Exposes functions such as `forEachPair`, `sample` or `flatten`. Much of the
* new functions are inspired by the methods of the Ruby Array class.
*/
@readonly
static Array = YoruArray;
/**
* Yoru.A
*
* Pseudo-constructor for YoruArray. Takes any number of arguments and convert
* those into a YoruArray.
* Passing an array to this function will result in a YoruArray containing one
* element (the native array itself).
*/
@readonly
static A() {
return new YoruArray(...arguments);
}
/* eslint-disable no-undef */
@readonly
static VERSION = VERSION;
/* eslint-enable no-undef */
}
!(function(Yoru) {
if (typeof window === typeof void 0 || typeof document === typeof void 0) {
console.error(
'Yoru cannot run in a headless JavaScript engine (missing `window` and/or `document`)'
);
throw new Error('Engine is headless');
}
window.Yoru = Yoru;
return Yoru;
})(Yoru);
export default Yoru;