Created
March 22, 2018 22:16
-
-
Save micheleriva/372ac38a5f1a612965a067ce35c13980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const encode = d => { | |
const newArr = []; | |
d.split('').map(c => { | |
newArr.push((c.charCodeAt(0) / 255)) | |
}) | |
return newArr | |
} | |
const encodeData = data => { | |
return data.map( d => { | |
return { | |
input: encode(d.input), | |
output: d.output | |
} | |
}) | |
} | |
const serialize = data => encodeData(data) | |
module.exports = { | |
serialize: serialize, | |
encode: encode, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment