UNPKG

@palasimi/ipa-cluster

Version:

Cluster words with similar IPA transcriptions together

33 lines 907 B
"use strict"; // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2023 Levi Gruspe // Sound operators. Object.defineProperty(exports, "__esModule", { value: true }); exports.concatenate = void 0; /** * Appends a sound to a sequence of sounds. */ function append(sequence, sound) { if (sound.length === 0) { return [sequence]; } return sound.map((segment) => [...sequence, segment]); } /** * Appends a sound to multiple sequences of sounds. */ function accumulate(sequences, sound) { if (sequences.length === 0) { return append([], sound); } return sequences.flatMap((sequence) => append(sequence, sound)); } /** * Concatenates any number of sounds. * Returns the array of possible concatenations. */ function concatenate(...sounds) { return sounds.reduce(accumulate, []); } exports.concatenate = concatenate; //# sourceMappingURL=operators.js.map