rdfjs-resource 1.0.21 → 1.0.22
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/Resource.d.ts +19 -0
- package/Resource.js +9 -6
- package/package.json +1 -1
package/Resource.d.ts
CHANGED
|
@@ -149,6 +149,11 @@ export declare namespace Resource {
|
|
|
149
149
|
objects: readonly ValueT[];
|
|
150
150
|
subject: Resource;
|
|
151
151
|
}): ArrayValues<ValueT>;
|
|
152
|
+
static fromValue<ValueT>(parameters: {
|
|
153
|
+
predicate: NamedNode;
|
|
154
|
+
object: ValueT;
|
|
155
|
+
subject: Resource;
|
|
156
|
+
}): SingletonValues<ValueT>;
|
|
152
157
|
head(): Either<ValueError, ValueT>;
|
|
153
158
|
map<NewValueT>(callback: (value: ValueT, index: number) => NewValueT): Values<NewValueT>;
|
|
154
159
|
abstract toArray(): readonly ValueT[];
|
|
@@ -182,5 +187,19 @@ declare class ArrayValues<ValueT> extends Resource.Values<ValueT> {
|
|
|
182
187
|
[Symbol.iterator](): Iterator<ValueT>;
|
|
183
188
|
toArray(): readonly ValueT[];
|
|
184
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Private implementation of Resource.Values that iterates over a single value.
|
|
192
|
+
*/
|
|
193
|
+
declare class SingletonValues<ValueT> extends Resource.Values<ValueT> {
|
|
194
|
+
readonly length = 1;
|
|
195
|
+
private readonly object;
|
|
196
|
+
constructor({ object, predicate, subject, }: {
|
|
197
|
+
object: ValueT;
|
|
198
|
+
predicate: NamedNode;
|
|
199
|
+
subject: Resource;
|
|
200
|
+
});
|
|
201
|
+
[Symbol.iterator](): Iterator<ValueT>;
|
|
202
|
+
toArray(): readonly ValueT[];
|
|
203
|
+
}
|
|
185
204
|
export {};
|
|
186
205
|
//# sourceMappingURL=Resource.d.ts.map
|
package/Resource.js
CHANGED
|
@@ -329,7 +329,7 @@ export class Resource {
|
|
|
329
329
|
return this.object;
|
|
330
330
|
}
|
|
331
331
|
toValues() {
|
|
332
|
-
return
|
|
332
|
+
return Values.fromValue({
|
|
333
333
|
object: this,
|
|
334
334
|
predicate: this.predicate,
|
|
335
335
|
subject: this.subject,
|
|
@@ -436,14 +436,14 @@ export class Resource {
|
|
|
436
436
|
newValues.push(callbackResult.extract());
|
|
437
437
|
valueI++;
|
|
438
438
|
}
|
|
439
|
-
return Either.of(
|
|
439
|
+
return Either.of(Values.fromArray({
|
|
440
440
|
objects: newValues,
|
|
441
441
|
predicate: this.predicate,
|
|
442
442
|
subject: this.subject,
|
|
443
443
|
}));
|
|
444
444
|
}
|
|
445
445
|
concat(...values) {
|
|
446
|
-
return
|
|
446
|
+
return Values.fromArray({
|
|
447
447
|
objects: this.toArray().concat(...values),
|
|
448
448
|
predicate: this.predicate,
|
|
449
449
|
subject: this.subject,
|
|
@@ -458,7 +458,7 @@ export class Resource {
|
|
|
458
458
|
}
|
|
459
459
|
valueI++;
|
|
460
460
|
}
|
|
461
|
-
return
|
|
461
|
+
return Values.fromArray({
|
|
462
462
|
objects: filteredValues,
|
|
463
463
|
predicate: this.predicate,
|
|
464
464
|
subject: this.subject,
|
|
@@ -491,7 +491,7 @@ export class Resource {
|
|
|
491
491
|
newValues.push(...callback(value, valueI));
|
|
492
492
|
valueI++;
|
|
493
493
|
}
|
|
494
|
-
return
|
|
494
|
+
return Values.fromArray({
|
|
495
495
|
objects: newValues,
|
|
496
496
|
predicate: this.predicate,
|
|
497
497
|
subject: this.subject,
|
|
@@ -500,6 +500,9 @@ export class Resource {
|
|
|
500
500
|
static fromArray(parameters) {
|
|
501
501
|
return new ArrayValues(parameters);
|
|
502
502
|
}
|
|
503
|
+
static fromValue(parameters) {
|
|
504
|
+
return new SingletonValues(parameters);
|
|
505
|
+
}
|
|
503
506
|
head() {
|
|
504
507
|
for (const value of this) {
|
|
505
508
|
return Either.of(value);
|
|
@@ -516,7 +519,7 @@ export class Resource {
|
|
|
516
519
|
newValues.push(callback(value, valueI));
|
|
517
520
|
valueI++;
|
|
518
521
|
}
|
|
519
|
-
return
|
|
522
|
+
return Values.fromArray({
|
|
520
523
|
objects: newValues,
|
|
521
524
|
predicate: this.predicate,
|
|
522
525
|
subject: this.subject,
|
package/package.json
CHANGED