| /* eslint-disable no-await-in-loop */ | |
| module.exports.dependencies = ['axios@0.27.2', '@cospired/i18n-iso-languages']; | |
| const details = () => ({ | |
| id: 'Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng', | |
| Stage: 'Pre-processing', | |
| Name: 'Remove all langs except native and English', | |
| Type: 'Audio', | |
| Operation: 'Transcode', | |
| Description: `This is a modified version made by gsariev of the original plugin. This plugin will remove all language audio tracks except the 'native' and user-specified languages. |
| // Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
| // Remove any duplicates from an array of primitives. | |
| const unique = [...new Set(arr)] | |
| // Sleep in async functions. Use: await sleep(2000). | |
| const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
| // or | |
| const sleep = util.promisify(setTimeout); |
Note:
When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.
If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:
- Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
| const maskDate = value => { | |
| let v = value.replace(/\D/g,'').slice(0, 10); | |
| if (v.length >= 5) { | |
| return `${v.slice(0,2)}/${v.slice(2,4)}/${v.slice(4)}`; | |
| } | |
| else if (v.length >= 3) { | |
| return `${v.slice(0,2)}/${v.slice(2)}`; | |
| } | |
| return v | |
| } |
Download the following repositories and run yarn install in each:
| const request = require("request"); | |
| const EventEmitter = require("events").EventEmitter; | |
| const util = require("util"); | |
| const endpoint = "https://discordapp.com/api/"; | |
| function DiscordWebhook(url) { | |
| this.url = url; | |
| this.onReady = false; | |
| var queue = []; |
Today, single page web apps are driving many websites that we use each and every day. Instead of having your browser request a new web page for each and every action you perform on a web page, single page web apps may load all in one request to smoothly and quickly transition with every action you perform.
When building single page web apps, you may decide to retrieve all of the HTML, CSS and Javascript with one single page load or dynamically load these resources as the user moves about your site. Either way, it can be a pain to bundle all of these assets together for the end user to download from your web server. This is where webpack comes into play.
webpack does all of the heavy lifting bundling all of your HTML, CSS and Javascript together. If you write your site all from scratch or depend on dependencies from npm, webpack takes care of packaging it all together for you. It has the ability to take your single page web app, cut out all of the code you don't need, then packa
You should almost never actually use this. The same applies to fs.stat (when used for checking existence).
Checking whether a file exists before doing something with it, can lead to race conditions in your application. Race conditions are extremely hard to debug and, depending on where they occur, they can lead to data loss or security holes. Using the synchronous versions will not fix this.
Generally, just do what you want to do, and handle the error if it doesn't work. This is much safer.
- If you want to check whether a file exists, before reading it: just try to open the file, and handle the
ENOENTerror when it doesn't exist. - If you want to make sure a file doesn't exist, before writing to it: open the file using an exclusive mode, eg.
wxorax, and handle the error when the file already exists.
