jscrewit 2.34.0 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api-doc/README.md CHANGED
@@ -14,20 +14,24 @@
14
14
  - [default](interfaces/default.md)
15
15
  - [encode](interfaces/encode.md)
16
16
 
17
- ### Type aliases
17
+ ### Type Aliases
18
18
 
19
19
  - [ElementaryFeatureName](README.md#elementaryfeaturename)
20
20
  - [FeatureElement](README.md#featureelement)
21
21
  - [FeatureElementOrCompatibleArray](README.md#featureelementorcompatiblearray)
22
22
  - [PredefinedFeatureName](README.md#predefinedfeaturename)
23
+ - [RunAs](README.md#runas)
23
24
 
24
25
  ### Variables
25
26
 
26
- - [Feature](README.md#feature)
27
27
  - [default](README.md#default)
28
+
29
+ ### Functions
30
+
31
+ - [Feature](README.md#feature)
28
32
  - [encode](README.md#encode)
29
33
 
30
- ## Type aliases
34
+ ## Type Aliases
31
35
 
32
36
  ### ElementaryFeatureName
33
37
 
@@ -43,7 +47,7 @@ ___
43
47
 
44
48
  A feature object or a name or alias of a predefined feature.
45
49
 
46
- **`remarks`**
50
+ **`Remarks`**
47
51
 
48
52
  Methods that accept parameters of this type throw an error if the specified value is neither a
49
53
  feature object nor a name or alias of a predefined feature.
@@ -57,7 +61,7 @@ ___
57
61
  A feature object, a name or alias of a predefined feature, or an array of such values that
58
62
  defines a union of mutually compatible features.
59
63
 
60
- **`remarks`**
64
+ **`Remarks`**
61
65
 
62
66
  Methods that accept parameters of this type throw an error if the specified value is neither a
63
67
  feature object nor a name or alias of a predefined feature, or if it is an array of values that
@@ -71,22 +75,92 @@ ___
71
75
 
72
76
  Name of a predefined feature.
73
77
 
74
- ## Variables
78
+ ___
75
79
 
76
- ### Feature
80
+ ### RunAs
77
81
 
78
- **Feature**: [`FeatureConstructor`](interfaces/FeatureConstructor.md)
82
+ Ƭ **RunAs**: ``"call"`` \| ``"eval"`` \| ``"express"`` \| ``"express-call"`` \| ``"express-eval"`` \| ``"none"``
79
83
 
80
- ___
84
+ Values of this type control the type of code generated from a given input.
85
+ See [`EncodeOptions.runAs`](interfaces/EncodeOptions.md#runas) for the meaning of each possible value.
86
+
87
+ ## Variables
81
88
 
82
89
  ### default
83
90
 
84
91
  • **default**: [`default`](README.md#default)
85
92
 
86
- JScrewIt object, available in Node.js.
93
+ ## Functions
94
+
95
+ ### Feature
96
+
97
+ ▸ **Feature**(`...features`): [`CustomFeature`](interfaces/CustomFeature.md)
98
+
99
+ Creates a new feature object from the union of the specified features.
100
+
101
+ The constructor can be used with or without the `new` operator, e.g.
102
+ `new JScrewIt.Feature(feature1, feature2)` or `JScrewIt.Feature(feature1, feature2)`.
103
+ If no arguments are specified, the new feature object will be equivalent to
104
+ [`DEFAULT`](interfaces/FeatureConstructor.md#default).
105
+
106
+ **`Example`**
107
+
108
+ The following statements are equivalent, and will all construct a new feature object
109
+ including both [`ANY_DOCUMENT`](interfaces/FeatureConstructor.md#any_document) and [`ANY_WINDOW`](interfaces/FeatureConstructor.md#any_window).
110
+
111
+ ```js
112
+ new JScrewIt.Feature("ANY_DOCUMENT", "ANY_WINDOW");
113
+ ```
114
+
115
+ ```js
116
+ new JScrewIt.Feature(JScrewIt.Feature.ANY_DOCUMENT, JScrewIt.Feature.ANY_WINDOW);
117
+ ```
118
+
119
+ ```js
120
+ new JScrewIt.Feature([JScrewIt.Feature.ANY_DOCUMENT, JScrewIt.Feature.ANY_WINDOW]);
121
+ ```
122
+
123
+ **`Throws`**
124
+
125
+ An error is thrown if any of the specified features are not mutually compatible.
126
+
127
+ #### Parameters
128
+
129
+ | Name | Type |
130
+ | :------ | :------ |
131
+ | `...features` | [`FeatureElementOrCompatibleArray`](README.md#featureelementorcompatiblearray)[] |
132
+
133
+ #### Returns
134
+
135
+ [`CustomFeature`](interfaces/CustomFeature.md)
87
136
 
88
137
  ___
89
138
 
90
139
  ### encode
91
140
 
92
- **encode**: [`encode`](README.md#encode)
141
+ **encode**(`input`, `options?`): `string`
142
+
143
+ Encodes a given string into JSFuck.
144
+
145
+ **`Throws`**
146
+
147
+ An `Error` is thrown under the following circumstances.
148
+ - The specified string cannot be encoded with the specified options.
149
+ - Some unknown features were specified.
150
+ - A combination of mutually incompatible features was specified.
151
+ - The option `runAs` (or `wrapWith`) was specified with an invalid value.
152
+
153
+ Also, an out of memory condition may occur when processing very large data.
154
+
155
+ #### Parameters
156
+
157
+ | Name | Type | Description |
158
+ | :------ | :------ | :------ |
159
+ | `input` | `string` | The string to encode. |
160
+ | `options?` | [`EncodeOptions`](interfaces/EncodeOptions.md) | An optional object specifying encoding options. |
161
+
162
+ #### Returns
163
+
164
+ `string`
165
+
166
+ The encoded string.
@@ -74,7 +74,7 @@ Feature.name
74
74
 
75
75
  ### includes
76
76
 
77
- ▸ **includes**(...`features`): `boolean`
77
+ ▸ **includes**(`...features`): `boolean`
78
78
 
79
79
  Determines whether this feature object includes all of the specified features.
80
80
 
@@ -111,7 +111,7 @@ that require strict mode code, or inside web workers.
111
111
 
112
112
  | Name | Type | Description |
113
113
  | :------ | :------ | :------ |
114
- | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
114
+ | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
115
115
  | `engineFeatureObjs?` | readonly [`PredefinedFeature`](PredefinedFeature.md)[] | An array of predefined feature objects, each corresponding to a particular engine in which the restriction should be enacted. If this parameter is omitted, the restriction is enacted in all engines. |
116
116
 
117
117
  #### Returns
@@ -71,7 +71,7 @@ ___
71
71
 
72
72
  ### includes
73
73
 
74
- ▸ **includes**(...`features`): `boolean`
74
+ ▸ **includes**(`...features`): `boolean`
75
75
 
76
76
  Determines whether this feature object includes all of the specified features.
77
77
 
@@ -108,7 +108,7 @@ that require strict mode code, or inside web workers.
108
108
 
109
109
  | Name | Type | Description |
110
110
  | :------ | :------ | :------ |
111
- | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
111
+ | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
112
112
  | `engineFeatureObjs?` | readonly [`PredefinedFeature`](PredefinedFeature.md)[] | An array of predefined feature objects, each corresponding to a particular engine in which the restriction should be enacted. If this parameter is omitted, the restriction is enacted in all engines. |
113
113
 
114
114
  #### Returns
@@ -17,15 +17,15 @@
17
17
 
18
18
  Specifies the features available in the engines that evaluate the encoded output.
19
19
 
20
- If this parameter is unspecified, [`JScrewIt.Feature.DEFAULT`](FeatureConstructor.md#default) is assumed: this
21
- ensures maximum compatibility but also generates the largest code.
20
+ If this parameter is unspecified, [`JScrewIt.Feature.DEFAULT`](FeatureConstructor.md#default) is assumed: this ensures maximum compatibility but also generates
21
+ the largest code.
22
22
  To generate shorter code, specify all features available in all target engines explicitly.
23
23
 
24
24
  ___
25
25
 
26
26
  ### runAs
27
27
 
28
- • `Optional` **runAs**: ``"call"`` \| ``"eval"`` \| ``"express"`` \| ``"express-call"`` \| ``"express-eval"`` \| ``"none"``
28
+ • `Optional` **runAs**: [`RunAs`](../README.md#runas)
29
29
 
30
30
  This option controls the type of code generated from the given input.
31
31
  Allowed values are listed below.
@@ -94,6 +94,6 @@ ___
94
94
 
95
95
  ### wrapWith
96
96
 
97
- • `Optional` **wrapWith**: ``"call"`` \| ``"eval"`` \| ``"express"`` \| ``"express-call"`` \| ``"express-eval"`` \| ``"none"``
97
+ • `Optional` **wrapWith**: [`RunAs`](../README.md#runas)
98
98
 
99
99
  An alias for `runAs`.
@@ -4,8 +4,8 @@ Objects of this type indicate which of the capabilities that JScrewIt can use to
4
4
  length of its output are available in a particular JavaScript engine.
5
5
 
6
6
  JScrewIt comes with a set of predefined feature objects exposed as property values of
7
- `JScrewIt.Feature` or [`JScrewIt.Feature.ALL`](FeatureConstructor.md#all), where the property name is the feature's
8
- name or alias.
7
+ `JScrewIt.Feature` or [`JScrewIt.Feature.ALL`](FeatureConstructor.md#all), where the property
8
+ name is the feature's name or alias.
9
9
 
10
10
  Besides these predefined features, it is possible to construct custom features from the union or
11
11
  intersection of other features.
@@ -16,10 +16,9 @@ they are different from such a union in that they exclude some other feature not
16
16
  their elementary components.
17
17
  All other features, called *composite* features, can be constructed as a union of zero or more
18
18
  elementary features.
19
- Two of the predefined composite features are particularly important: <code>[DEFAULT](FeatureConstructor.md#default)</code> is
20
- the empty feature, indicating that no elementary feature is available at all;
21
- <code>[AUTO](FeatureConstructor.md#auto)</code> is the union of all elementary features available in the current
22
- environment.
19
+ Two of the predefined composite features are particularly important: [`DEFAULT`](FeatureConstructor.md#default) is the empty feature, indicating that no elementary
20
+ feature is available at all; [`AUTO`](FeatureConstructor.md#auto) is the union of all
21
+ elementary features available in the current environment.
23
22
 
24
23
  Not all features can be available at the same time: some features are necessarily incompatible,
25
24
  meaning that they mutually exclude each other, and thus their union cannot be constructed.
@@ -78,7 +77,7 @@ If a name is assigned, it will be used when the feature is converted into a stri
78
77
 
79
78
  ### includes
80
79
 
81
- ▸ **includes**(...`features`): `boolean`
80
+ ▸ **includes**(`...features`): `boolean`
82
81
 
83
82
  Determines whether this feature object includes all of the specified features.
84
83
 
@@ -111,7 +110,7 @@ that require strict mode code, or inside web workers.
111
110
 
112
111
  | Name | Type | Description |
113
112
  | :------ | :------ | :------ |
114
- | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
113
+ | `environment` | ``"forced-strict-mode"`` \| ``"web-worker"`` | The environment to which this feature should be restricted. Two environments are currently supported. <dl> <dt><code>"forced-strict-mode"</code></dt> <dd> Removes features that are not available in environments that require strict mode code. </dd> <dt><code>"web-worker"</code></dt> <dd>Removes features that are not available inside web workers.</dd> </dl> |
115
114
  | `engineFeatureObjs?` | readonly [`PredefinedFeature`](PredefinedFeature.md)[] | An array of predefined feature objects, each corresponding to a particular engine in which the restriction should be enacted. If this parameter is omitted, the restriction is enacted in all engines. |
116
115
 
117
116
  #### Returns