You are reading content from Scuttlebutt
@mikey
Re: %rs1cBaXeC

lately i've been using ramda:

const { any, endsWith } = require('ramda')

const isMediaFileName = any(endsWith([".mp4", ".m4v", ".webm", ".ogg", ".mp3"]))

if (isMediaFileName(fileName)) {
  // ...
}

also easy to implement without ramda:

const endsWith = (ending) => (string) => string.endsWith(ending)
const any = (array) => (predicate) => array.some(predicate)
@mix
Re: %rs1cBaXeC

I'd go

var ACCEPTED_FORMATS = ['mp4, 'm4v', 'webm', 'ogg', 'mp3']
var extension = name.match(/.*\.(\w+)$/)[1]  // or use some module

if (~ACCEPTED_FORMATS.indexOf(extension)) {
  content_file = file
}

that ~ is a gross js hack... and lodash can make a bunch of this pretty obsolete if you want to use that

@mix
Voted this
@neftaly
Voted this
@2mas
Voted this
@2mas
Re: %rs1cBaXeC

Ramda seams awesome. There's a lot of documentation. Good to see nice digestible bite sized solutions!

@ivanoats
Voted this
Join Scuttlebutt now