UNPKG

yandex-music

Version:

Creative and progressive Node.js framework for applications that interact with yandex music

34 lines (33 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Difference = void 0; var Operations; (function (Operations) { Operations["INSERT"] = "insert"; Operations["DELETE"] = "delete"; })(Operations || (Operations = {})); class Difference { /** * Adding an insertion operation. * @param {null} at Index to insert. * @param {Array<Track>} tracks An object with unique track IDs and . * @returns JSON stringify operation */ static insert(at, tracks) { const operation = { op: Operations.INSERT, at: at, tracks: [] }; for (const { id, albumId } of tracks) operation["tracks"].push({ id, albumId }); return JSON.stringify(operation); } /** * The range for deleting tracks is passed. * @param {null} from From which index. * @param {null} to By what index. * @returns JSON stringify operation */ static delete(from, to) { const operation = { op: Operations.DELETE, from: from, to: to }; return JSON.stringify(operation); } } exports.Difference = Difference;