Fixed return value for map

main
Jackson Morgan 7 months ago
parent 10ec863635
commit 7abe0fa587
  1. 8
      packages/jsonld-dataset-proxy/src/setProxy/ldSet/BasicLdSet.ts
  2. 2
      packages/jsonld-dataset-proxy/src/setProxy/ldSet/LdSet.ts

@ -34,12 +34,12 @@ export class BasicLdSet<T> extends Set<T> implements LdSet<T> {
}
}
map<U>(callbackfn: (value: T, set: LdSet<T>) => U, thisArg?: any): LdSet<U> {
const newSet = new BasicLdSet<U>();
map<U>(callbackfn: (value: T, set: LdSet<T>) => U, thisArg?: any): U[] {
const returnValues: U[] = [];
for (const value of this) {
newSet.add(callbackfn.call(thisArg, value, this));
returnValues.push(callbackfn.call(thisArg, value, this));
}
return newSet;
return returnValues;
}
filter<S extends T>(

@ -96,7 +96,7 @@ interface LdSet<T> extends Set<T> {
* @param callbackfn A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the set.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
map<U>(callbackfn: (value: T, set: LdSet<T>) => U, thisArg?: any): LdSet<U>;
map<U>(callbackfn: (value: T, set: LdSet<T>) => U, thisArg?: any): U[];
/**
* Returns the elements of a set that meet the condition specified in a callback function.
* @param predicate A function that accepts up to two arguments. The filter method calls the predicate function one time for each element in the set.

Loading…
Cancel
Save