// SPDX-FileCopyrightText: In 2019, Chris Pressey, the original author of this work, placed it into the public domain.
// SPDX-License-Identifier: Unlicense
// For more information, please refer to <https://unlicense.org/>
import { bless } from '../contrib/concoctor-0.2/concoctor.js';
/* --[ Immutable Map accessors ]------------------------------------------------- */
const newMap = bless(() => Immutable.Map({}));
const get = bless((obj, key) => obj.get(key));
const set = bless((obj, key, val) => obj.set(key, val));
const setr = bless((key, val, obj) => obj.set(key, val));
const update = bless((obj, key, updater) => obj.update(key, updater));
/* --[ Immutable List accessors ]------------------------------------------------ */
const newList = bless(() => Immutable.List());
const push = bless((li, item) => li.push(item));
const map = bless((li, mapper) => li.map(mapper));
const reduce = bless((li, reducer, acc) => li.reduce(reducer, acc));
const rep = bless(function(n, makeItem) {
const items = [];
for (let i = 0; i < n; i++) {
items.push(makeItem(i));
}
return Immutable.List(items);
}, { signature: ["number", "function"]});
export {
newMap, get, set, setr, update,
newList, push, map, reduce, rep
}