hunk

1.0.6 • Public • Published

hunk Build Status

Multipart files, one hunk at a time.

Getting Started

Install the module with: npm install hunk

Documentation

hunk( String ) : Array|Object

Accepts a string representing multiple documents, delimited by triple hypens (---), just like YAML. Delimiters may be named by appending any text you want after the hypens (---foo), unlike YAML.

Examples

Usage

var fs = require('fs');
var hunk = require('hunk');
 
fs.readFile('foo.hnk', 'utf8', function (err, data) {
    console.log(hunk(data));
});

Array

Input (foo.hnk):

---
hello world
---
foo
---
bar
---

Output:

['hello world', 'foo', 'bar']

Object

Input (foo.hnk):

---hello
world
---foo
bar
---
baz
---

Output:

{
    hello: 'world',
    foo: 'bar',
    2: 'baz'
}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 1.0.5: Better handling of whitespace.

License

Copyright (c) 2013 Shannon Moeller. Licensed under the MIT license.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.6
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.6
    1
  • 1.0.5
    0
  • 1.0.4
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i hunk

Weekly Downloads

1

Version

1.0.6

License

none

Last publish

Collaborators

  • shannonmoeller