Skip to content

A very basic encoder & decoder for testing purposes

License

Notifications You must be signed in to change notification settings

DPulavarthy/endecodify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kurasad#2521

Logo

💠 Endecodify 💠

A very basic encoder & decoder for testing purposes
Visit the creator »

Contact · Report Bug · Request Feature

Installation

Install using npm

npm install endecodify

Usage

Require the module

// CASE I
let endecodify = require(`endecodify`)
endecodify.startup() // Parameters: [References] A boolean to control if references to this module should be made under "process".
// Checking process.argv only happens when the startup function is called
// Startup return an object with the status of the module

// CASE II
let { startup } = require(`endecodify`)
startup()

// CASE III
require(`endecodify`).startup() // I recommend this :)

Examples

A few examples on the usage of this module

// CASE I
require(`endecodify`).startup()

console.log(process.encode(`Hello World!`)) // Returns:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/
console.log(process.decode(`8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW`)) // Returns: 
/* 

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/
// CASE II
let { startup, encode, decode } = require(`endecodify`)
startup(true) // Removes declarations under "process"

console.log(encode(`Hello World!`)) // Returns:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/

console.log(decode(`8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW`)) // Returns: 
/* 

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/
// CASE III
node . encode Hello World! // Returns [In Console]:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/
node . decode 8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW // Returns [In Console]:
/*

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/

Possible Error Situations

Some errors that can possibly occur

// CASE I
let { startup } = require(`endecodify`)
startup() // Returns { case: 'success', code: '200', message: 'Successfully setup' }
startup() // Returns throw new Error(`Setup function has already been called`)

// CASE II
let { startup, encode, decode } = require(`endecodify`)
encode("Hello World!") // Returns throw new Error(`Setup function has not been called`)

// CASE III
// Inputting unknown or broken values will throw an error defaulted by the process

About

A very basic encoder & decoder for testing purposes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published