JSFiddle - React, Tailwind, and code Playground

by jvns

JavaScript

// Freesound API JavaScript Client
// API documentation: http://www.freesound.org/docs/api/

(function(name, definition) {
// CommonJS + AMD + Browser global
// http://stackoverflow.com/a/14033636/1729279
    if (typeof module != 'undefined'){
        module.exports = definition();
    }
    else if (typeof define == 'function' && typeof define.amd == 'object')
        define(name,[],definition);
    else
        this[name] = definition();
}('freesound', function() {

var request;
if (typeof module != 'undefined'){ 
    request = require("request");
}

var freesound = {
    BASE_URI : "http://www.freesound.org/api",
    apiKey : '',
    debug: true,
    _URI_SOUND : '/sounds/<sound_id>/',
    _URI_SOUND_ANALYSIS : '/sounds/<sound_id>/analysis/',
    _URI_SOUND_ANALYSIS_FILTER :'/sounds/<sound_id>/analysis/<filter>',
    _URI_SIMILAR_SOUNDS : '/sounds/<sound_id>/similar/',
    _URI_SEARCH : '/sounds/search/',
    _URI_CONTENT_SEARCH : '/sounds/content_search/',
    _URI_GEOTAG : '/sounds/geotag/',
    _URI_USER : '/people/<user_name>/',
    _URI_USER_SOUNDS : '/people/<user_name>/sounds/',
    _URI_USER_PACKS : '/people/<user_name>/packs/',
    _URI_USER_BOOKMARKS : '/people/<username>/bookmark_categories',
    _URI_BOOKMARK_CATEGORY_SOUNDS : '/people/<username>/bookmark_categories/<category_id>/sounds',
    _URI_PACK : '/packs/<pack_id>/',
    _URI_PACK_SOUNDS : '/packs/<pack_id>/sounds/',

    _make_uri : function(uri,args){
        for (var a in args) {uri = uri.replace(/<[\w_]+>/, args[a]);}
        return this.BASE_URI+uri;
    },
    _make_request : function(uri,success,error,params,wrapper){
        var fs = this;
        var parse_response = function(response){
            var data = eval("(" + response + ")");
            success(wrapper?wrapper(data):data);
        }
        if(uri.indexOf('?') == -1){ uri = uri+"?"; }
        uri = uri+"&api_key="+this.apiKey;
        for(var p in params){uri = uri+"&"+p+"="+params[p];}
        if(this.debug)...