mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 14:20:51 +02:00
22.0.0
This commit is contained in:
@@ -12,11 +12,14 @@ module.exports = class BinaryCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (this.binary(text).length < 2000) return true;
|
||||
return 'Your text is too long.';
|
||||
validate: (text) => {
|
||||
if (this.binary(text).length < 2000) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Your text is too long.';
|
||||
}
|
||||
},
|
||||
parse: text => this.binary(text)
|
||||
parse: (text) => this.binary(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -28,7 +31,7 @@ module.exports = class BinaryCommand extends Command {
|
||||
}
|
||||
|
||||
binary(text) {
|
||||
return unescape(encodeURIComponent(text)).split('').map(str => {
|
||||
return unescape(encodeURIComponent(text)).split('').map((str) => {
|
||||
const converted = str.charCodeAt(0).toString(2);
|
||||
return `${'00000000'.slice(converted.length)}${converted}`;
|
||||
}).join('');
|
||||
|
||||
Reference in New Issue
Block a user