[Pkg-javascript-commits] [node-zfill] 01/04: Imported Upstream version 0.0.2

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sat Jun 28 05:36:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-zfill.

commit 2b2cfb0d88ea8877b1d47b3fe65af853d5a43c52
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Sat Jun 28 05:32:12 2014 +0000

    Imported Upstream version 0.0.2
---
 .gitignore   |  1 +
 README.md    | 10 ++++++++++
 index.js     |  7 +++++++
 package.json | 19 +++++++++++++++++++
 test.js      |  7 +++++++
 5 files changed, 44 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..07e6e47
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/node_modules
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9da16f5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,10 @@
+# zfill
+
+## Usage
+
+```js
+var zfill = require('zfill');
+
+console.log(zfill(9, 2)); // prints '09'
+console.log(zfill(1234, 3)); // prints '1234'
+```
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..f6a965c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,7 @@
+module.exports = zfill;
+
+function zfill(number, size) {
+  number = number.toString();
+  while (number.length < size) number = "0" + number;
+  return number;
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..33632d3
--- /dev/null
+++ b/package.json
@@ -0,0 +1,19 @@
+{
+  "name": "zfill",
+  "version": "0.0.2",
+  "description": "simple function to pad a number with zeroes",
+  "main": "index.js",
+  "scripts": {
+    "test": "node test.js"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/andrewrk/node-zfill.git"
+  },
+  "author": "Andrew Kelley",
+  "license": "BSD",
+  "bugs": {
+    "url": "https://github.com/andrewrk/node-zfill/issues"
+  },
+  "homepage": "https://github.com/andrewrk/node-zfill"
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..1e6fa44
--- /dev/null
+++ b/test.js
@@ -0,0 +1,7 @@
+var assert = require('assert');
+var zfill = require('./');
+
+assert.strictEqual(zfill(2772, 3), "2772");
+assert.strictEqual(zfill(2772, 5), "02772");
+assert.strictEqual(zfill("12345", 3), "12345");
+assert.strictEqual(zfill("123", 8), "00000123");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-zfill.git



More information about the Pkg-javascript-commits mailing list