Skip to content

Commit 7b159a6

Browse files
committed
initial import
0 parents  commit 7b159a6

File tree

11 files changed

+2349
-0
lines changed

11 files changed

+2349
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.DS_Store

.jshintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"indent": 4,
3+
"node": true,
4+
"globalstrict": true,
5+
"evil": true,
6+
"unused": true,
7+
"undef": true,
8+
"newcap": true,
9+
"esnext": true,
10+
"curly": true,
11+
"eqeqeq": true,
12+
13+
"predef": [
14+
"describe",
15+
"it"
16+
]
17+
}

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.travis.yml
2+
.jshintrc
3+
Gruntfile.js
4+
test

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
- "0.11"
5+
before_install:
6+
- npm install -g grunt-cli
7+
notifications:
8+
email:
9+

Gruntfile.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = function(grunt) {
2+
'use strict';
3+
4+
// Project configuration.
5+
grunt.initConfig({
6+
jshint: {
7+
all: ['*.js', 'src/*.js', 'test/*.js'],
8+
options: {
9+
jshintrc: '.jshintrc'
10+
}
11+
},
12+
13+
mochaTest: {
14+
all: {
15+
options: {
16+
reporter: 'spec'
17+
},
18+
src: ['test/*-unit.js']
19+
}
20+
}
21+
});
22+
23+
// Load the plugin(s)
24+
grunt.loadNpmTasks('grunt-contrib-jshint');
25+
grunt.loadNpmTasks('grunt-mocha-test');
26+
27+
// Tasks
28+
grunt.registerTask('default', ['jshint', 'mochaTest']);
29+
};

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2014 Andris Reinman
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# libbase64
2+
3+
Encode and decode base64 strings.
4+
5+
## Usage
6+
7+
Install with npm
8+
9+
npm install libbase64
10+
11+
Require in your script
12+
13+
```javascript
14+
var libbase64 = require('libbase64');
15+
```
16+
17+
### Encode values
18+
19+
Encode Buffer objects or unicode strings with
20+
21+
libbase64.encode(val) → String
22+
23+
Where
24+
25+
* **val** is a Buffer or an unicode string
26+
27+
**Example**
28+
29+
```javascript
30+
libbase64.encode('jõgeva');
31+
// asO1Z2V2YQ==
32+
```
33+
34+
### Wrap encoded values
35+
36+
To enforce soft line breaks on lines longer than selected amount of characters, use `wrap`
37+
38+
libbase64.wrap(str[, lineLength]) → String
39+
40+
Where
41+
42+
* **str** is a base64 encoded string
43+
* **lineLength** (defaults to 76) is the maximum allowed line length
44+
45+
**Example**
46+
47+
```javascript
48+
libbase64.wrap('asO1Z2V2asO1Z2V2asO1Z2V2YQ==', 10)
49+
// asO1Z2V2as\r\n
50+
// O1Z2V2asO1\r\n
51+
// Z2V2YQ==
52+
```
53+
54+
### Transform Streams
55+
56+
`libbase64` makes it possible to encode and decode streams with `libbase64.Encoder` and `libbase64.Decoder` constructors.
57+
58+
### Encoder Stream
59+
60+
Create new Encoder Stream with
61+
62+
var encoder = new libbase64.Encoder([options])
63+
64+
Where
65+
66+
* **options** is the optional stream options object with an additional option `lineLength` if you want to use any other line length than the default 76 characters (or set to `false` to turn the soft wrapping off completely)
67+
68+
**Example**
69+
70+
The following example script reads in a file, encodes it to base64 and saves the output to a file.
71+
72+
```javascript
73+
var libbase64 = require('libbase64');
74+
var fs = require('fs');
75+
var source = fs.createReadStream('source.txt');
76+
var encoded = fs.createReadStream('encoded.txt');
77+
var encoder = new libbase64.Encoder();
78+
79+
source.pipe(encoder).pipe(encoded);
80+
```
81+
82+
### Decoder Stream
83+
84+
Create new Decoder Stream with
85+
86+
var decoder = new libbase64.Decoder([options])
87+
88+
Where
89+
90+
* **options** is the optional stream options object
91+
92+
**Example**
93+
94+
The following example script reads in a file in base64 encoding, decodes it and saves the output to a file.
95+
96+
```javascript
97+
var libbase64 = require('libbase64');
98+
var fs = require('fs');
99+
var encoded = fs.createReadStream('encoded.txt');
100+
var dest = fs.createReadStream('dest.txt');
101+
var decoder = new libbase64.Decoder();
102+
103+
encoded.pipe(decoder).pipe(dest);
104+
```
105+
106+
## License
107+
108+
**MIT**

0 commit comments

Comments
 (0)