diff --git a/README.md b/README.md
index 58a7ede..7b11062 100644
--- a/README.md
+++ b/README.md
@@ -35,5 +35,9 @@ var eol = require('eol')
- Add linebreak after text
- @return string with linebreak added after text
+### `eol.split(text)`
+- Split text by newline
+- @return array of lines
+
## License
MIT
diff --git a/eol.d.ts b/eol.d.ts
index cb6d530..51d25a0 100644
--- a/eol.d.ts
+++ b/eol.d.ts
@@ -34,6 +34,12 @@ declare module eol {
* @return string with linebreak added after text
*/
export function after(text: string): string;
+
+ /**
+ * Split text by newline
+ * @return array of lines
+ */
+ export function split(text: string): Array;
}
declare module "eol" {
diff --git a/eol.js b/eol.js
index 958c45b..21d4fd1 100644
--- a/eol.js
+++ b/eol.js
@@ -22,11 +22,16 @@
}
}
+ function split(text) {
+ return text.split(newline)
+ }
+
api['lf'] = converts('\n')
api['cr'] = converts('\r')
api['crlf'] = converts('\r\n')
api['auto'] = converts(linebreak)
api['before'] = before
api['after'] = after
+ api['split'] = split
return api
});
diff --git a/test.js b/test.js
index 0a7e3a0..e2b8dd3 100644
--- a/test.js
+++ b/test.js
@@ -23,6 +23,11 @@
aok('lf repeat newlines intact', eol.lf('\n\n\r\r') === '\n\n\n\n')
aok('cr repeat newlines intact', eol.cr('\n\n\r\r') === '\r\r\r\r')
aok('crlf repeat newlines intact', eol.crlf('\r\n\r\n') === '\r\n\r\n')
+ aok('split return type', eol.split('0\n1\n2') instanceof Array)
+ aok('split lf', eol.split('0\n1\n2').join('') === '012')
+ aok('split cr', eol.split('0\r1\r2').join('') === '012')
+ aok('split crlf', eol.split('0\r\n1\r\n2').join('') === '012')
+ aok('split mixed', eol.split('0\r\n1\n2\r3\r\n4').join('') === '01234')
aok.pass(meths, function(method, i) {
var normalized = eol[method](sample)