@comunica/actor-function-factory-term-str-before 5.1.0 → 5.2.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/LICENSE.txt +22 -0
- package/lib/TermFunctionStrBefore.js +11 -36
- package/lib/TermFunctionStrBefore.js.map +1 -1
- package/package.json +5 -4
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -4,7 +4,6 @@ exports.TermFunctionStrBefore = void 0;
|
|
|
4
4
|
const bus_function_factory_1 = require("@comunica/bus-function-factory");
|
|
5
5
|
const utils_expression_evaluator_1 = require("@comunica/utils-expression-evaluator");
|
|
6
6
|
const Helpers_1 = require("@comunica/utils-expression-evaluator/lib/functions/Helpers");
|
|
7
|
-
const Errors_1 = require("@comunica/utils-expression-evaluator/lib/util/Errors");
|
|
8
7
|
/**
|
|
9
8
|
* https://www.w3.org/TR/sparql11-query/#func-strbefore
|
|
10
9
|
*/
|
|
@@ -14,43 +13,19 @@ class TermFunctionStrBefore extends bus_function_factory_1.TermFunctionBase {
|
|
|
14
13
|
arity: 2,
|
|
15
14
|
operator: utils_expression_evaluator_1.SparqlOperator.STRBEFORE,
|
|
16
15
|
overloads: (0, utils_expression_evaluator_1.declare)(utils_expression_evaluator_1.SparqlOperator.STRBEFORE)
|
|
17
|
-
.
|
|
18
|
-
.onBinary([utils_expression_evaluator_1.TypeURL.RDF_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => (arg1, arg2) => {
|
|
16
|
+
.onCompatibleStringly2(() => (arg1, arg2) => {
|
|
19
17
|
const [a1, a2] = [arg1.typedValue, arg2.typedValue];
|
|
20
|
-
const sub =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return sub || !a2 ? (0, utils_expression_evaluator_1.langString)(sub, arg1.language) : (0, utils_expression_evaluator_1.string)(sub);
|
|
30
|
-
})
|
|
31
|
-
.onBinary([utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => (arg1, arg2) => {
|
|
32
|
-
const [a1, a2] = [arg1.typedValue, arg2.typedValue];
|
|
33
|
-
const sub = arg1.typedValue.slice(0, Math.max(0, a1.indexOf(a2)));
|
|
34
|
-
return sub || !a2 ? (0, Helpers_1.dirLangString)(sub, arg1.language, arg1.direction) : (0, utils_expression_evaluator_1.string)(sub);
|
|
35
|
-
})
|
|
36
|
-
.onBinary([utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING, utils_expression_evaluator_1.TypeURL.RDF_LANG_STRING], () => (arg1, arg2) => {
|
|
37
|
-
if (arg1.language !== arg2.language) {
|
|
38
|
-
throw new utils_expression_evaluator_1.IncompatibleLanguageOperation(arg1, arg2);
|
|
18
|
+
const sub = a1.slice(0, Math.max(0, a1.indexOf(a2)));
|
|
19
|
+
if (sub || !a2) {
|
|
20
|
+
if (arg1.dataType === utils_expression_evaluator_1.TypeURL.RDF_LANG_STRING) {
|
|
21
|
+
return (0, utils_expression_evaluator_1.langString)(sub, arg1.language);
|
|
22
|
+
}
|
|
23
|
+
if (arg1.dataType === utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING) {
|
|
24
|
+
return (0, Helpers_1.dirLangString)(sub, arg1.language, arg1.direction);
|
|
25
|
+
}
|
|
26
|
+
return (0, utils_expression_evaluator_1.string)(sub, arg1.dataType);
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
const sub = arg1.typedValue.slice(0, Math.max(0, a1.indexOf(a2)));
|
|
42
|
-
return sub || !a2 ? (0, Helpers_1.dirLangString)(sub, arg1.language, arg1.direction) : (0, utils_expression_evaluator_1.string)(sub);
|
|
43
|
-
})
|
|
44
|
-
.onBinary([utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING, utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING], () => (arg1, arg2) => {
|
|
45
|
-
if (arg1.language !== arg2.language) {
|
|
46
|
-
throw new utils_expression_evaluator_1.IncompatibleLanguageOperation(arg1, arg2);
|
|
47
|
-
}
|
|
48
|
-
if (arg1.direction !== arg2.direction) {
|
|
49
|
-
throw new Errors_1.IncompatibleDirectionalLanguageOperation(arg1, arg2);
|
|
50
|
-
}
|
|
51
|
-
const [a1, a2] = [arg1.typedValue, arg2.typedValue];
|
|
52
|
-
const sub = arg1.typedValue.slice(0, Math.max(0, a1.indexOf(a2)));
|
|
53
|
-
return sub || !a2 ? (0, Helpers_1.dirLangString)(sub, arg1.language, arg1.direction) : (0, utils_expression_evaluator_1.string)(sub);
|
|
28
|
+
return (0, utils_expression_evaluator_1.string)(sub);
|
|
54
29
|
})
|
|
55
30
|
.collect(),
|
|
56
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TermFunctionStrBefore.js","sourceRoot":"","sources":["TermFunctionStrBefore.ts"],"names":[],"mappings":";;;AAAA,yEAAkE;
|
|
1
|
+
{"version":3,"file":"TermFunctionStrBefore.js","sourceRoot":"","sources":["TermFunctionStrBefore.ts"],"names":[],"mappings":";;;AAAA,yEAAkE;AAKlE,qFAM8C;AAE9C,wFAA2F;AAE3F;;GAEG;AACH,MAAa,qBAAsB,SAAQ,uCAAgB;IACzD;QACE,KAAK,CAAC;YACJ,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,2CAAc,CAAC,SAAS;YAClC,SAAS,EAAE,IAAA,oCAAO,EAAC,2CAAc,CAAC,SAAS,CAAC;iBACzC,qBAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;gBAC1C,MAAM,CAAE,EAAE,EAAE,EAAE,CAAE,GAAG,CAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAE,CAAC;gBACxD,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACrD,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBACf,IAAI,IAAI,CAAC,QAAQ,KAAK,oCAAO,CAAC,eAAe,EAAE,CAAC;wBAC9C,OAAO,IAAA,uCAAU,EAAC,GAAG,EAAuB,IAAK,CAAC,QAAQ,CAAC,CAAC;oBAC9D,CAAC;oBACD,IAAI,IAAI,CAAC,QAAQ,KAAK,oCAAO,CAAC,mBAAmB,EAAE,CAAC;wBAClD,OAAO,IAAA,uBAAa,EAClB,GAAG,EACqB,IAAK,CAAC,QAAQ,EACd,IAAK,CAAC,SAAS,CACxC,CAAC;oBACJ,CAAC;oBACD,OAAO,IAAA,mCAAM,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACpC,CAAC;gBACD,OAAO,IAAA,mCAAM,EAAC,GAAG,CAAC,CAAC;YACrB,CAAC,CAAC;iBACD,OAAO,EAAE;SACb,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,sDA2BC","sourcesContent":["import { TermFunctionBase } from '@comunica/bus-function-factory';\nimport type {\n\n LangStringLiteral,\n} from '@comunica/utils-expression-evaluator';\nimport {\n declare,\n langString,\n SparqlOperator,\n string,\n TypeURL,\n} from '@comunica/utils-expression-evaluator';\nimport type { DirLangStringLiteral } from '@comunica/utils-expression-evaluator/lib/expressions';\nimport { dirLangString } from '@comunica/utils-expression-evaluator/lib/functions/Helpers';\n\n/**\n * https://www.w3.org/TR/sparql11-query/#func-strbefore\n */\nexport class TermFunctionStrBefore extends TermFunctionBase {\n public constructor() {\n super({\n arity: 2,\n operator: SparqlOperator.STRBEFORE,\n overloads: declare(SparqlOperator.STRBEFORE)\n .onCompatibleStringly2(() => (arg1, arg2) => {\n const [ a1, a2 ] = [ arg1.typedValue, arg2.typedValue ];\n const sub = a1.slice(0, Math.max(0, a1.indexOf(a2)));\n if (sub || !a2) {\n if (arg1.dataType === TypeURL.RDF_LANG_STRING) {\n return langString(sub, (<LangStringLiteral> arg1).language);\n }\n if (arg1.dataType === TypeURL.RDF_DIR_LANG_STRING) {\n return dirLangString(\n sub,\n (<DirLangStringLiteral> arg1).language,\n (<DirLangStringLiteral> arg1).direction,\n );\n }\n return string(sub, arg1.dataType);\n }\n return string(sub);\n })\n .collect(),\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-function-factory-term-str-before",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "A term-str-before function-factory actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"build:components": "componentsjs-generator"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@comunica/bus-function-factory": "^5.
|
|
41
|
-
"@comunica/utils-expression-evaluator": "^5.
|
|
42
|
-
}
|
|
40
|
+
"@comunica/bus-function-factory": "^5.2.0",
|
|
41
|
+
"@comunica/utils-expression-evaluator": "^5.2.0"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "ebb0e79bddcd850fcb8d0fb5b422af88e67fa283"
|
|
43
44
|
}
|