asajs 4.0.12 → 4.0.13
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RandomBindingString, ResolveBinding } from "../../components/Utils.js";
|
|
1
|
+
import { RandomBindingString, RandomString, ResolveBinding } from "../../components/Utils.js";
|
|
2
2
|
import { bindingFuntions } from "../Configuration.js";
|
|
3
3
|
import { isString } from "./Checker.js";
|
|
4
4
|
export const FunctionMap = new Map();
|
|
@@ -119,25 +119,56 @@ export const defaultFunctions = {
|
|
|
119
119
|
},
|
|
120
120
|
contains: (source_str, contains_str) => {
|
|
121
121
|
return {
|
|
122
|
-
value: `
|
|
122
|
+
value: `not ((${source_str} - ${contains_str}) = ${source_str})`,
|
|
123
123
|
};
|
|
124
124
|
},
|
|
125
125
|
starts_with: (source_str, start_str) => {
|
|
126
|
-
const
|
|
127
|
-
if (isString(
|
|
128
|
-
start_str
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
const prefix = `'asajs:${RandomString(5)}:'`;
|
|
127
|
+
if (isString(source_str)) {
|
|
128
|
+
if (isString(start_str)) {
|
|
129
|
+
return {
|
|
130
|
+
value: `${source_str.slice(1, -1).startsWith(start_str.slice(1, -1))}`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
source_str = prefix.slice(0, -1) + source_str.slice(1);
|
|
135
|
+
const start_str_bind = RandomBindingString();
|
|
136
|
+
return {
|
|
137
|
+
genBindings: [
|
|
138
|
+
{
|
|
139
|
+
source: `${prefix} + ${start_str}`,
|
|
140
|
+
target: start_str_bind,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
value: `not ((${source_str} - ${start_str_bind}) = ${source_str})`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (isString(start_str)) {
|
|
149
|
+
const strLength = start_str.length - 2;
|
|
150
|
+
return {
|
|
151
|
+
value: `('%.${strLength}s' * ${source_str} = ${start_str})`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const source_str_bind = RandomBindingString();
|
|
156
|
+
const start_str_bind = RandomBindingString();
|
|
157
|
+
return {
|
|
158
|
+
genBindings: [
|
|
159
|
+
{
|
|
160
|
+
source: `${prefix} + ${source_str}`,
|
|
161
|
+
target: source_str_bind,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
source: `${prefix} + ${start_str}`,
|
|
165
|
+
target: start_str_bind,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
value: `not ((${source_str_bind} - ${start_str_bind}) = ${source_str_bind})`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
141
172
|
},
|
|
142
173
|
/**
|
|
143
174
|
* Return a translatable string
|