Skip to content

Commit

Permalink
v1.1.0 add custom modes via function prop MODES
Browse files Browse the repository at this point in the history
  • Loading branch information
mster committed Jun 25, 2020
1 parent ad5ac92 commit 3240ee4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/mosh.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ const path = require('path')

const MoshError = require('./error')

const MODES = {
blurbobb: require('./modes/blurbobb'),
schifty: require('./modes/schifty')
}

module.exports = mosh

function mosh (options, cb) {
Expand Down Expand Up @@ -44,8 +39,8 @@ function mosh (options, cb) {
/* If mode is unset, randomly select one */
const _mode =
mode == null
? Object.keys(MODES)[
Math.floor(Math.random() * Object.keys(MODES).length)
? Object.keys(mosh.MODES)[
Math.floor(Math.random() * Object.keys(mosh.MODES).length)
]
: mode
debug(`Mode selected: ${_mode}`)
Expand All @@ -58,7 +53,7 @@ function mosh (options, cb) {

function doMosh (original) {
debug('Moshing')
return MODES[_mode](original)
return mosh.MODES[_mode](original)
}

function writeMosh (moshed) {
Expand All @@ -75,3 +70,8 @@ function mosh (options, cb) {
cb(new MoshError(error))
}
}

mosh.MODES = {
blurbobb: require('./modes/blurbobb'),
schifty: require('./modes/schifty')
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datamosh",
"version": "1.0.1",
"version": "1.1.0",
"description": "Datamosh images",
"keywords": ["datamost", "mosh", "jpg", "png", "glitch"],
"author": "Michael Sterpka <[email protected]>",
Expand Down

0 comments on commit 3240ee4

Please sign in to comment.