Permalink
Browse files

first

  • Loading branch information...
0 parents commit 9ad3a68a8e31982cef7048575855aba943feea4c @mcandre committed Mar 20, 2012
Showing with 62 additions and 0 deletions.
  1. +19 −0 README.md
  2. +22 −0 chop.js
  3. +21 −0 package.json
@@ -0,0 +1,19 @@
+# chop - A chop()/chomp() library for Node.js
+
+## EXAMPLE
+
+ $ node
+ > var chop = require("./chop");
+ undefined
+ > chop.chop("Howdy!");
+ 'Howdy'
+ > chop.chop("Howdy!\n");
+ 'Howdy!'
+ > chop.chop("Howdy!\n\n");
+ 'Howdy!\n'
+ > chop.chomp("Howdy!\n\n");
+ 'Howdy!'
+ > chop.chomp("Howdy!\r\n");
+ 'Howdy!'
+ > chop.chop("Howdy!\r\n");
+ 'Howdy!\r'
22 chop.js
@@ -0,0 +1,22 @@
+function chop(s) {
+ return s.slice(0, s.length - 1);
+}
+
+exports.chop = chop;
+
+function chomp(s) {
+ if (s.length < 1) {
+ return s;
+ }
+ else {
+ var result = s.slice(0, s.length);
+
+ while (result.length > 1 && result[result.length - 1] == '\n' || result[result.length - 1] == '\r') {
+ result = result.slice(0, result.length - 1);
+ }
+
+ return result;
+ }
+}
+
+exports.chomp = chomp;
@@ -0,0 +1,21 @@
+{
+ "name": "chop",
+ "description": "A chop()/chomp() library for Node.js",
+ "version": "0.0.1",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mcandre/node-chop.git"
+ },
+ "author": "Andrew Pennebaker <andrew.pennebaker@gmail.com> (http://www.yellosoft.us/)",
+ "main": "chop",
+ "directories": {
+ "lib": "."
+ },
+ "scripts": {
+ },
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {
+ }
+}

0 comments on commit 9ad3a68

Please sign in to comment.