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AT,EAAmB,CACzB,EAAQ,YAAc,QAAQ,IAAI,mDACtC,QACD,CACA,GAAe,CAChB,CAAE,MAAO,GACR,QAAQ,IAAI,EACb,CAID,QAAQ,IAAI,GAEZ,EAAQ,EAAY,GAEtB,CA/GA,OAAO,eAAe,IAAK,QAAS,CAMnC,MAAM,GACE,kBAAkB,IAE1B,UAAU,IAGX,OAAO,eAAe,IAAK,OAAQ,CAMlC,MAAM,GACE,sBAAsB,IAE9B,UAAU,IAiGX,OAAO,QAAU,CAChB,OAAQ,OACR,QAAS,QACT,IAAK,IACL,SAAU,IAAI,KACd,UAAW,IAAI","file":"/npm/sourcebin-lite@0.0.4/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/sourcebin-lite@0.0.4/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const request = require('request');\r\n\r\n/**\r\n * @name url\r\n * @param {string} key the key to the sourcebin\r\n * @returns {string} creates the url to the sourcebin\r\n */\r\nfunction url(key) {\r\n\treturn `https://sourceb.in/${key}`\r\n};\r\n\r\nObject.defineProperty(url, 'short', {\r\n\t/**\r\n\t *\r\n\t * @param {string} key the key to the sourcebin\r\n\t * @returns {string} the short url to the sourcebin\r\n\t */\r\n\tvalue(key) {\r\n\t\treturn `http://srcb.in/${key}`\r\n\t},\r\n\twritable: false\r\n});\r\n\r\nObject.defineProperty(url, 'long', {\r\n\t/**\r\n\t * @function value\r\n\t * @param {string} key the key to the sourcebin\r\n\t * @returns {string} the long url to the sourcebin\r\n\t */\r\n\tvalue(key) {\r\n\t\treturn `https://sourceb.in/${key}`\r\n\t},\r\n\twritable: false\r\n})\r\n\r\n/**\r\n *\r\n * @param {string} title what do you want to name the sourcebin\r\n * @param {string} code put the code you want to save to it here\r\n * @returns\r\n */\r\nasync function create(title, code, options = { title: \"null\", description: \"None\" }) {\r\n\tif (Array.isArray(code)) { return console.log(''); };\r\n\tif (typeof code !== 'string') { return console.log('code must be a string'); };\r\n\tif (typeof title !== 'string') { return console.log('title must be a string'); };\r\n\treturn new Promise((resolve, reject) => {\r\n\t\trequest({\r\n\t\t\t'url': \"https://sourceb.in/api/bins/\",\r\n\t\t\t'method': \"POST\",\r\n\t\t\tjson: {\r\n\t\t\t\tfiles: [\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\"name\": title,\r\n\t\t\t\t\t\t\"content\": code\r\n\t\t\t\t\t}\r\n\t\t\t\t],\r\n\t\t\t\t...options\r\n\t\t\t},\r\n\t\t}, (err, res, body) => {\r\n\t\t\tif (err) { return reject(err); };\r\n\t\t\tresolve(url(body.key));\r\n\t\t});\r\n\t});\r\n};\r\n\r\n\r\n\r\n/**\r\n * @name get_key\r\n * @param {string} url get the key of the sourcebin\r\n * @returns {string} the key to the sourcebin\r\n */\r\nfunction get_key(url) {\r\n\tlet url_regex = new RegExp('https\\:\\/\\/sourceb\\.in\\/|http\\:\\/\\/srcb\\.in\\/');\r\n\tif (typeof url !== 'string') return console.log('make sure inputted url is a string');\r\n\tif (!url_regex.test(url)) return console.log('not a valid sourcebin link')\r\n\treturn url.replace(url_regex, '');\r\n};\r\n\r\n\r\n/**\r\n *\r\n * @param {string} key the key to the sourcebin\r\n * @param {{ enableLogs: boolean }} options the only option rn is to disable and enable logs sorry its not a required option\r\n * @returns {string} the code in the files\r\n */\r\nasync function read(key, options = { enableLogs: false }) {\r\n\treturn new Promise(async (resolve, reject) => {\r\n\r\n\t\tlet return_data = '';\r\n\r\n\t\tlet first = await new Promise((resolve, reject) => {\r\n\t\t\trequest.get(`https://sourceb.in/api/bins/${key}`, {}, (err, res, body) => {\r\n\t\t\t\tif (err) { reject(err); };\r\n\t\t\t\tresolve(JSON.parse(body));\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\tfor (let i = 0; i < first.files.length; i++) {\r\n\t\t\ttry {\r\n\t\t\t\tconst text = await new Promise((resolve, reject) => {\r\n\t\t\t\t\trequest.get(`https://cdn.sourceb.in/bins/${key}/${i}`, {}, (err, res, body) => {\r\n\t\t\t\t\t\tif (err) { reject(err); };\r\n\t\t\t\t\t\tresolve(body);\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (typeof text !== 'string') {\r\n\t\t\t\t\tif (options.enableLogs) { console.log('one of the files had an error fetching the data'); };\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\treturn_data += text;\r\n\t\t\t} catch (err) {\r\n\t\t\t\tconsole.log(err)\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\tconsole.log(return_data)\r\n\r\n\t\tresolve(return_data);\r\n\t});\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\nmodule.exports = {\r\n\tcreate: create,\r\n\tget_key: get_key,\r\n\turl: url,\r\n\tlong_url: url.long,\r\n\tshort_url: url.short\r\n};\r\n"]}