1
0
mirror of https://github.com/gabemart/hipku.git synced 2024-10-05 18:30:54 +01:00
hipku/README.md

38 lines
1.1 KiB
Markdown
Raw Normal View History

2014-12-13 23:01:35 +00:00
# Hipku
2014-12-12 00:31:14 +00:00
A tiny javascript library to encode IPv6 and IPv4 addresses as haiku.
2019-01-31 18:24:51 +00:00
For full documentation and a working demo, check out https://gabrielbrady.com/projects/hipku
2014-12-13 23:01:35 +00:00
## Installation
2016-09-02 18:17:16 +01:00
Install with `npm install hipku`. `index.js` can also be used directly in the browser.
2014-12-13 23:01:35 +00:00
## Usage
To encode `127.0.0.1` or `::1` call `Hipku.encode('127.0.0.1')` or `Hipku.encode('::1')`. IPv4 addresses must have octets separated by a `.` period character and IPv6 addresses must have hextets separated by a `:` colon character.
When decoding a hipku, such as:
The weary red dove
fights in the empty tundra.
Jasmine petals dance.
2016-09-02 18:17:16 +01:00
2014-12-13 23:01:35 +00:00
the lines can be separated either by the newline character `\n` or by a space. Both will produce the same result.
Hipku.decode('The weary red dove\nfights in the empty tundra.\nJasmine petals dance.');
2016-09-02 18:17:16 +01:00
2014-12-13 23:01:35 +00:00
> "254.53.93.114"
2016-09-02 18:17:16 +01:00
2014-12-13 23:01:35 +00:00
Hipku.decode('The weary red dove fights in the empty tundra. Jasmine petals dance.');
2016-09-02 18:17:16 +01:00
2014-12-13 23:01:35 +00:00
> "254.53.93.114"
2016-09-02 18:17:16 +01:00
2014-12-13 23:01:35 +00:00
### Node.js
var hipku = require('hipku');
2015-02-24 12:42:03 +00:00
hipku.encode('127.0.0.1');
2014-12-13 23:01:35 +00:00
hipku.decode('The weary red dove fights in the empty tundra. Jasmine petals dance.');