Skip to content

Instantly share code, notes, and snippets.

View Tarabyte's full-sized avatar
🏠
Working from home

Yury Tarabanko Tarabyte

🏠
Working from home
  • Belgorod, Russia
View GitHub Profile
@Tarabyte
Tarabyte / file.js
Last active February 28, 2019 12:24
Nested callbacks
addStepsAttachments(fileName, folder, callback) {
fileName = '12345';
fs.readdir(folder, 'utf8', function(err, filesList) {
if (!err && filesList.length > 0) {
const results = [];
const matchingFiles = filesList
.filter(file => file.startsWith(fileName))
.map(file => path.resolve(folder, file));
// just in case there were no matching files
/**
* Code which I test on twitter.com
* Both tests were runing in Chrome 35.x dev tools
*
* This test just gets all a tags from html and read their content
* and then write it on end of document (body element)
*
**/