Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

soundcloud.ts

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soundcloud.ts - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

30

dist/entities/Playlists.js

@@ -52,27 +52,15 @@ "use strict";

this.fetch = function (playlist) { return __awaiter(_this, void 0, void 0, function () {
var i, _a, _b, _c;
var unresolvedTracks, _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
i = 0;
_d.label = 1;
unresolvedTracks = playlist.tracks.splice(playlist.tracks.findIndex(function (t) { return !t.title; })).map(function (t) { return t.id; });
if (unresolvedTracks.length === 0)
return [2 /*return*/, playlist];
_a = playlist;
_c = (_b = playlist.tracks).concat;
return [4 /*yield*/, this.tracks.getArrayV2(unresolvedTracks)];
case 1:
if (!(i < playlist.tracks.length)) return [3 /*break*/, 6];
if (!!playlist.tracks[i].title) return [3 /*break*/, 5];
_d.label = 2;
case 2:
_d.trys.push([2, 4, , 5]);
_a = playlist.tracks;
_b = i;
return [4 /*yield*/, this.tracks.getV2(playlist.tracks[i].id)];
case 3:
_a[_b] = _d.sent();
return [3 /*break*/, 5];
case 4:
_c = _d.sent();
return [3 /*break*/, 5];
case 5:
i++;
return [3 /*break*/, 1];
case 6: return [2 /*return*/, playlist];
_a.tracks = _c.apply(_b, [_d.sent()]);
return [2 /*return*/, playlist];
}

@@ -79,0 +67,0 @@ });

@@ -26,2 +26,6 @@ import api from "../API";

/**
* Fetches tracks from an array of ID using Soundcloud v2 API.
*/
getArrayV2: (trackIds: number[]) => Promise<SoundcloudTrackV2[]>;
/**
* @deprecated

@@ -28,0 +32,0 @@ * Fetches all comments on a track.

@@ -114,2 +114,27 @@ "use strict";

/**
* Fetches tracks from an array of ID using Soundcloud v2 API.
*/
this.getArrayV2 = function (trackIds) { return __awaiter(_this, void 0, void 0, function () {
var chunks, i, response, tracks;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (trackIds.length === 0)
return [2 /*return*/, []
// Max 50 ids per request => split into chunks of 50 ids
];
chunks = [];
i = 0;
while (i < trackIds.length)
chunks.push(trackIds.slice(i, (i += 50)));
response = [];
return [4 /*yield*/, Promise.all(chunks.map(function (chunk) { return _this.api.getV2("/tracks", { ids: chunk.join(",") }); }))];
case 1:
tracks = _a.sent();
return [2 /*return*/, response.concat.apply(response, tracks)];
}
});
}); };
/**
* @deprecated

@@ -116,0 +141,0 @@ * Fetches all comments on a track.

@@ -15,11 +15,5 @@ import axios from "axios"

public fetch = async (playlist: SoundcloudPlaylistV2) => {
for (let i = 0; i < playlist.tracks.length; i++) {
if (!playlist.tracks[i].title) {
try {
playlist.tracks[i] = await this.tracks.getV2(playlist.tracks[i].id)
} catch {
// Ignore
}
}
}
const unresolvedTracks = playlist.tracks.splice(playlist.tracks.findIndex(t => !t.title)).map(t => t.id)
if (unresolvedTracks.length === 0) return playlist
playlist.tracks = playlist.tracks.concat(await this.tracks.getArrayV2(unresolvedTracks))
return playlist

@@ -26,0 +20,0 @@ }

@@ -47,2 +47,16 @@ import axios from "axios"

/**
* Fetches tracks from an array of ID using Soundcloud v2 API.
*/
public getArrayV2 = async (trackIds: number[]) => {
if (trackIds.length === 0) return []
// Max 50 ids per request => split into chunks of 50 ids
const chunks: number[][] = []
let i = 0
while (i < trackIds.length) chunks.push(trackIds.slice(i, (i += 50)))
const response: SoundcloudTrackV2[] = []
const tracks = await Promise.all(chunks.map(chunk => this.api.getV2(`/tracks`, { ids: chunk.join(",") })))
return response.concat(...tracks)
}
/**
* @deprecated

@@ -49,0 +63,0 @@ * Fetches all comments on a track.

{
"name": "soundcloud.ts",
"version": "0.4.6",
"version": "0.4.7",
"description": "Wrapper for the Soundcloud API with typings",

@@ -5,0 +5,0 @@ "main": "dist/soundcloud.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc