@comunica/actor-function-factory-term-replace 4.5.0 → 5.0.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/README.md CHANGED
@@ -31,7 +31,7 @@ After installing, this package can be added to your engine's configuration as fo
31
31
  {
32
32
  "@context": [
33
33
  ...
34
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^4.0.0/components/context.jsonld"
34
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^5.0.0/components/context.jsonld"
35
35
  ],
36
36
  "actors": [
37
37
  ...
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^4.0.0/components/context.jsonld",
4
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-function-factory/^4.0.0/components/context.jsonld",
5
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^4.0.0/components/context.jsonld"
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^5.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-function-factory/^5.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
6
6
  ],
7
7
  "@id": "npmd:@comunica/actor-function-factory-term-replace",
8
8
  "components": [
@@ -35,37 +35,37 @@
35
35
  "genericTypeInstances": [
36
36
  {
37
37
  "@type": "ParameterRangeGenericTypeReference",
38
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
38
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
39
39
  },
40
40
  {
41
41
  "@type": "ParameterRangeGenericTypeReference",
42
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
42
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
43
43
  },
44
44
  {
45
45
  "@type": "ParameterRangeGenericTypeReference",
46
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
46
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
47
47
  },
48
48
  {
49
49
  "@type": "ParameterRangeGenericTypeReference",
50
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
50
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
51
51
  }
52
52
  ]
53
53
  },
54
54
  {
55
55
  "@type": "ParameterRangeGenericTypeReference",
56
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
56
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
57
57
  },
58
58
  {
59
59
  "@type": "ParameterRangeGenericTypeReference",
60
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
60
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
61
61
  },
62
62
  {
63
63
  "@type": "ParameterRangeGenericTypeReference",
64
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
64
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
65
65
  },
66
66
  {
67
67
  "@type": "ParameterRangeGenericTypeReference",
68
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
68
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
69
69
  }
70
70
  ]
71
71
  },
@@ -102,19 +102,19 @@
102
102
  "genericTypeInstances": [
103
103
  {
104
104
  "@type": "ParameterRangeGenericTypeReference",
105
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
105
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
106
106
  },
107
107
  {
108
108
  "@type": "ParameterRangeGenericTypeReference",
109
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
109
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
110
110
  },
111
111
  {
112
112
  "@type": "ParameterRangeGenericTypeReference",
113
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
113
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
114
114
  },
115
115
  {
116
116
  "@type": "ParameterRangeGenericTypeReference",
117
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
117
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
118
118
  }
119
119
  ]
120
120
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^4.0.0/components/context.jsonld"
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-function-factory-term-replace/^5.0.0/components/context.jsonld"
4
4
  ],
5
5
  "@id": "npmd:@comunica/actor-function-factory-term-replace",
6
6
  "@type": "Module",
@@ -3,7 +3,7 @@
3
3
  "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
4
4
  {
5
5
  "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
- "cafftr": "npmd:@comunica/actor-function-factory-term-replace/^4.0.0/",
6
+ "cafftr": "npmd:@comunica/actor-function-factory-term-replace/^5.0.0/",
7
7
  "ActorFunctionFactoryTermReplace": {
8
8
  "@id": "cafftr:components/ActorFunctionFactoryTermReplace.jsonld#ActorFunctionFactoryTermReplace",
9
9
  "@prefix": true,
File without changes
File without changes
File without changes
File without changes
@@ -4,6 +4,7 @@ exports.TermFunctionReplace = void 0;
4
4
  const actor_function_factory_term_regex_1 = require("@comunica/actor-function-factory-term-regex");
5
5
  const bus_function_factory_1 = require("@comunica/bus-function-factory");
6
6
  const utils_expression_evaluator_1 = require("@comunica/utils-expression-evaluator");
7
+ const Helpers_1 = require("@comunica/utils-expression-evaluator/lib/functions/Helpers");
7
8
  /**
8
9
  * https://www.w3.org/TR/sparql11-query/#func-replace
9
10
  */
@@ -17,11 +18,19 @@ class TermFunctionReplace extends bus_function_factory_1.TermFunctionBase {
17
18
  .set([utils_expression_evaluator_1.TypeURL.RDF_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => ([arg, pattern, replacement]) => {
18
19
  const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue);
19
20
  return (0, utils_expression_evaluator_1.langString)(result, arg.language);
21
+ })
22
+ .set([utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => ([arg, pattern, replacement]) => {
23
+ const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue);
24
+ return (0, Helpers_1.dirLangString)(result, arg.language, arg.direction);
20
25
  })
21
26
  .onQuaternaryTyped([utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => (arg, pattern, replacement, flags) => (0, utils_expression_evaluator_1.string)(TermFunctionReplace.replace(arg, pattern, replacement, flags)))
22
27
  .set([utils_expression_evaluator_1.TypeURL.RDF_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => ([arg, pattern, replacement, flags]) => {
23
28
  const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue, flags.typedValue);
24
29
  return (0, utils_expression_evaluator_1.langString)(result, arg.language);
30
+ })
31
+ .set([utils_expression_evaluator_1.TypeURL.RDF_DIR_LANG_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING, utils_expression_evaluator_1.TypeURL.XSD_STRING], () => ([arg, pattern, replacement, flags]) => {
32
+ const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue, flags.typedValue);
33
+ return (0, Helpers_1.dirLangString)(result, arg.language, arg.direction);
25
34
  })
26
35
  .collect(),
27
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TermFunctionReplace.js","sourceRoot":"","sources":["TermFunctionReplace.ts"],"names":[],"mappings":";;;AAAA,mGAAgF;AAChF,yEAAkE;AAMlE,qFAM8C;AAE9C;;GAEG;AACH,MAAa,mBAAoB,SAAQ,uCAAgB;IACvD;QACE,KAAK,CAAC;YACJ,KAAK,EAAE,CAAE,CAAC,EAAE,CAAC,CAAE;YACf,QAAQ,EAAE,2CAAc,CAAC,OAAO;YAChC,SAAS,EAAE,IAAA,oCAAO,EAAC,2CAAc,CAAC,OAAO,CAAC;iBACvC,cAAc,CACb,CAAE,oCAAO,CAAC,UAAU,EAAE,oCAAO,CAAC,UAAU,EAAE,oCAAO,CAAC,UAAU,CAAE,EAC9D,GAAG,EAAE,CAAC,CAAC,GAAW,EAAE,OAAe,EAAE,WAAmB,EAAE,EAAE,CAC1D,IAAA,mCAAM,EAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CACjE;iBACA,GAAG,CACF,CAAE,oCAAO,CAAC,eAAe,EAAE,oCAAO,CAAC,UAAU,EAAE,oCAAO,CAAC,UAAU,CAAE,EACnE,GAAG,EAAE,CAAC,CAAC,CAAE,GAAG,EAAE,OAAO,EAAE,WAAW,CAAqD,EAAE,EAAE;gBACzF,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;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ACD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,qDAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,KAAK,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC;QAC7C,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;CACF;AAtDD,kDAsDC","sourcesContent":["import { TermFunctionRegex } from '@comunica/actor-function-factory-term-regex';\nimport { TermFunctionBase } from '@comunica/bus-function-factory';\nimport type {\n StringLiteral,\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';\n\n/**\n * https://www.w3.org/TR/sparql11-query/#func-replace\n */\nexport class TermFunctionReplace extends TermFunctionBase {\n public constructor() {\n super({\n arity: [ 3, 4 ],\n operator: SparqlOperator.REPLACE,\n overloads: declare(SparqlOperator.REPLACE)\n .onTernaryTyped(\n [ TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => (arg: string, pattern: string, replacement: string) =>\n string(TermFunctionReplace.replace(arg, pattern, replacement)),\n )\n .set(\n [ TypeURL.RDF_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement ]: [LangStringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue);\n return langString(result, arg.language);\n },\n )\n .onQuaternaryTyped(\n [ TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => (arg: string, pattern: string, replacement: string, flags: string) =>\n string(TermFunctionReplace.replace(arg, pattern, replacement, flags)),\n )\n .set(\n [ TypeURL.RDF_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement, flags ]:\n [LangStringLiteral, StringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(\n arg.typedValue,\n pattern.typedValue,\n replacement.typedValue,\n flags.typedValue,\n );\n return langString(result, arg.language);\n },\n )\n .collect(),\n });\n }\n\n // https://www.w3.org/TR/xpath-functions/#func-replace\n private static replace(arg: string, pattern: string, replacement: string, flags = ''): string {\n flags = TermFunctionRegex.cleanFlags(flags);\n if (flags.includes('x')) {\n pattern = TermFunctionRegex.flagX(pattern);\n }\n if (flags.includes('q')) {\n pattern = TermFunctionRegex.flagQ(pattern);\n } else {\n replacement = replacement.replaceAll('$0', () => '$&');\n }\n flags = `${flags.replaceAll(/[qx]/gu, '')}g`;\n return arg.replaceAll(new RegExp(pattern, flags), replacement);\n }\n}\n"]}
1
+ {"version":3,"file":"TermFunctionReplace.js","sourceRoot":"","sources":["TermFunctionReplace.ts"],"names":[],"mappings":";;;AAAA,mGAAgF;AAChF,yEAAkE;AAMlE,qFAM8C;AAE9C,wFAA2F;AAE3F;;GAEG;AACH,MAAa,mBAAoB,SAAQ,uCAAgB;IACvD;QACE,KAAK,CAAC;YACJ,KAAK,EAAE,CAAE,CAAC,EAAE,CAAC,CAAE;YACf,QAAQ,EAAE,2CAAc,CAAC,OAAO;YAChC,SAAS,EAAE,IAAA,oCAAO,EAAC,2CAAc,CAAC,OAAO,CAAC;iBACvC,cAAc,CACb,CAAE,oCAAO,CAAC,UAAU,EAAE,oCAAO,CAAC,UAAU,EAAE,oCAAO,CAAC,UAAU,CAAE,EAC9D,GAAG,EAAE,CAAC,CAAC,GAAW,EAAE,OAAe,EAAE,WAAmB,EAAE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CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,qDAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,qDAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,KAAK,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC;QAC7C,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;CACF;AA1ED,kDA0EC","sourcesContent":["import { TermFunctionRegex } from '@comunica/actor-function-factory-term-regex';\nimport { TermFunctionBase } from '@comunica/bus-function-factory';\nimport type {\n StringLiteral,\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-replace\n */\nexport class TermFunctionReplace extends TermFunctionBase {\n public constructor() {\n super({\n arity: [ 3, 4 ],\n operator: SparqlOperator.REPLACE,\n overloads: declare(SparqlOperator.REPLACE)\n .onTernaryTyped(\n [ TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => (arg: string, pattern: string, replacement: string) =>\n string(TermFunctionReplace.replace(arg, pattern, replacement)),\n )\n .set(\n [ TypeURL.RDF_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement ]: [LangStringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue);\n return langString(result, arg.language);\n },\n )\n .set(\n [ TypeURL.RDF_DIR_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement ]: [DirLangStringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(arg.typedValue, pattern.typedValue, replacement.typedValue);\n return dirLangString(result, arg.language, arg.direction);\n },\n )\n .onQuaternaryTyped(\n [ TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => (arg: string, pattern: string, replacement: string, flags: string) =>\n string(TermFunctionReplace.replace(arg, pattern, replacement, flags)),\n )\n .set(\n [ TypeURL.RDF_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement, flags ]:\n [LangStringLiteral, StringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(\n arg.typedValue,\n pattern.typedValue,\n replacement.typedValue,\n flags.typedValue,\n );\n return langString(result, arg.language);\n },\n )\n .set(\n [ TypeURL.RDF_DIR_LANG_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING, TypeURL.XSD_STRING ],\n () => ([ arg, pattern, replacement, flags ]:\n [DirLangStringLiteral, StringLiteral, StringLiteral, StringLiteral]) => {\n const result = TermFunctionReplace.replace(\n arg.typedValue,\n pattern.typedValue,\n replacement.typedValue,\n flags.typedValue,\n );\n return dirLangString(result, arg.language, arg.direction);\n },\n )\n .collect(),\n });\n }\n\n // https://www.w3.org/TR/xpath-functions/#func-replace\n private static replace(arg: string, pattern: string, replacement: string, flags = ''): string {\n flags = TermFunctionRegex.cleanFlags(flags);\n if (flags.includes('x')) {\n pattern = TermFunctionRegex.flagX(pattern);\n }\n if (flags.includes('q')) {\n pattern = TermFunctionRegex.flagQ(pattern);\n } else {\n replacement = replacement.replaceAll('$0', () => '$&');\n }\n flags = `${flags.replaceAll(/[qx]/gu, '')}g`;\n return arg.replaceAll(new RegExp(pattern, flags), replacement);\n }\n}\n"]}
package/lib/index.d.ts CHANGED
File without changes
package/lib/index.js CHANGED
File without changes
package/lib/index.js.map CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-function-factory-term-replace",
3
- "version": "4.5.0",
3
+ "version": "5.0.0",
4
4
  "description": "A term-replace function-factory actor",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -37,9 +37,9 @@
37
37
  "build:components": "componentsjs-generator"
38
38
  },
39
39
  "dependencies": {
40
- "@comunica/actor-function-factory-term-regex": "^4.5.0",
41
- "@comunica/bus-function-factory": "^4.5.0",
42
- "@comunica/utils-expression-evaluator": "^4.5.0"
40
+ "@comunica/actor-function-factory-term-regex": "^5.0.0",
41
+ "@comunica/bus-function-factory": "^5.0.0",
42
+ "@comunica/utils-expression-evaluator": "^5.0.0"
43
43
  },
44
- "gitHead": "2bcd98c387a021fc5c08d375793c205ca3d1bf0d"
44
+ "gitHead": "0b1756fdb9bef014133432489627c1bd71779bd0"
45
45
  }