Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Dec 2, 2014
0 parents commit 448f1f2
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
# use line feed
end_of_line = lf

# ensure file ends with a newline when saving
insert_final_newline = true

# soft tabs
indent_style = space

# number of columns used for each indentation level
indent_size = 2

# remove any whitespace characters preceding newline characters
trim_trailing_whitespace = true

# character set
charset = utf-8
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Convert line endings to LF (Line Feed)
* text=auto
103 changes: 103 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//this will affect all the git repos
git config --global core.excludesfile ~/.gitignore


//update files since .ignore won't if already tracked
git rm --cached <file>

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
# Icon?
ehthumbs.db
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject

# Numerous always-ignore extensions #
#####################################
*.diff
*.err
*.orig
*.rej
*.swn
*.swo
*.swp
*.vi
*~
*.sass-cache
*.grunt
*.tmp

# Dreamweaver added files #
###########################
_notes
dwsync.xml

# Komodo #
###########################
*.komodoproject
.komodotools

# Node #
#####################
node_modules

# Bower #
#####################
bower_components

# Folders to ignore #
#####################
.hg
.svn
.CVS
intermediate
publish
.idea
.graphics
_test
_archive
uploads
tmp

# Vim files to ignore #
#######################
.VimballRecord
.netrwhist
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.2 - 2014-11-26
### Changed
- `slopeAngle.calc()` to simply `slopeAngle()`
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT license

Copyright (C) 2014 Miguel Mota

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Commafy

# Install

```bash
npm install commafy
```

# Usage

```javascript
commafy(1000000) // '1,000,000'
```

# License

MIT
22 changes: 22 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "commafy",
"main": "commafy.js",
"version": "0.0.1",
"homepage": "https://github.com/miguelmota/commafy",
"authors": [
"Miguel Mota <miguelmota2@gmail.com>"
],
"description": "Add commas to a number",
"keywords": [
"number",
"commafy"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"license": "MIT"
}
16 changes: 16 additions & 0 deletions commafy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(function(){

function commafy(n) {
if (!n) { return n; }
var parts = n.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return parts.join('.');
}

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = commafy;
} else {
window.commafy = commafy;
}

})();
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "commafy",
"version": "0.0.1",
"description": "Add commas to a number",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "tape test/*.js"
},
"repository": {
"type": "git",
"url": "https://github.com/miguelmota/commafy"
},
"keywords": [
"number",
"commas"
],
"author": "Miguel Mota <hello@miguelmota.com> (http://www.miguelmota.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/miguelmota/commafy/issues"
},
"homepage": "https://github.com/miguelmota/commafy",
"dependencies": {
"tape": "^3.0.3"
}
}
15 changes: 15 additions & 0 deletions test/commafy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var test = require('tape');
var commafy = require('../commafy');

test('commafy', function (t) {
t.plan(8);

t.equal(commafy(1000000), '1,000,000');
t.equal(commafy(1000), '1,000');
t.equal(commafy(100), '100');
t.equal(commafy(85), '85');
t.equal(commafy(10200.50), '10,200.5');
t.equal(commafy((10200.50).toFixed(3)), '10,200.500');
t.equal(commafy(1000.5023), '1,000.5023');
t.equal(commafy(14734534.53), '14,734,534.53');
});

0 comments on commit 448f1f2

Please sign in to comment.