Skip to content

Commit

Permalink
WIP #4
Browse files Browse the repository at this point in the history
  • Loading branch information
leodido committed Mar 7, 2016
1 parent 9577906 commit f0a124f
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 95 deletions.
11 changes: 0 additions & 11 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ node_modules
bower_components

.idea
*.sublime*

.zuulrc


7 changes: 4 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test.js
bower.json
**/.*
gulpfile.babel.js
test/
bower.json
node_modules/
*.log
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: node_js
language: node_js'
matrix:
include:
- node_js: "iojs"
env: SAUCELABS=false
- node_js: "0.10"
env: SAUCELABS=false
- node_js: "0.12"
- node_js: "stable"
env: SAUCELABS=true
- node_js: "4"
env: SAUCELABS=true
- node_js: "0.12"
env: SAUCELABS=false
cache:
directories:
- node_modules
Expand All @@ -22,7 +22,6 @@ deploy:
secure: QG0di2PIjXr0V1hQupe9HRbiE7OvB/XUt7Jjc6tqKTJbF7KFKPqE1fZBPwdJk76Q8jp2E+2XTWFKg/Y2H681XL0ehEWHMf14VxSLVNCjNLyiTM5EgbryW5emHLeSbQZDQ8TMK84u+ZPmgnNp+3QuuOerDqpOEQMJX4SxyWFDCLfUSBF2fLOAbjiyJy6cbjKuAjM5SN+fQ0l4uOmOE8pQhpryjlmjniOh1EjQTGCtR1G4NRQnWvon7p5cgdMyXhioXOT5UjFFAeqUrDaNycLf8ufPOzsCdVOZC6YUFb90AFlrSEsVO9wA9hoCAGUb9hU7fK6JabLD7AxNVlzGUYP0r0Oge+QWmNlgs94f5FZb7Uvho91aTYl5JaHMra2OoBvCaym8kcUFqgdAXWMgZod1wwg138z6vhqqhU5p8X3VgQuAe1ztly053Rm9s8VbkxzKWrBPJNVlfEvmQKAHkZklrDk7kYcCz2k5YGy8qV+vzfUH/5jVhJllTxo9q21BWvPHed6y6PSZvZkoCCFsL66jHdjREyeH8J7MQfaB8aDtqQJ1eXfjTWMvKGQRONUHt1x7q4TiGs8CtuGW1ZAPiNoZGCqPbLBcHLlPY3kwhwqfSv3MP8U1PhT6lbnZrI6IkvUWegivZDmYCV11fYvEB3pkZ6ZdOKOXp6EQVSqSfV0jUqw=
on:
tags: true
node_js: "0.12"
repo: leodido/luhn.js
notifications:
email: false
5 changes: 0 additions & 5 deletions .zuul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ browsers:
capabilities:
recordScreenshots: false
videoUploadOnPass: false

browserify:
- transform:
name: babelify
optional: runtime
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 1.1.0

* Support for node.js 0.12, 4 and latest stable
* Half the sizes of the bundles
(production: ~350 bytes, development: ~700 bytes)
* Location of bundles changed to directory **lib/**
* Tests for ~ 50 browsers

# 1.0.1

* Initial release
* UMD bundle
* Support for node.js 0.10, 0.12 and io.js
* Tests for ~ 50 browsers
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Leonardo Di Donato
Copyright (c) 2016 Leonardo Di Donato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ This algorithm (also known as [Luhn formula](https://en.wikipedia.org/wiki/Luhn_

### Install

~1KB.
**~ 500 bytes**.

[UMD](https://github.com/umdjs/umd) builds for development - **index.js** and **index.js.map** - and production - **index.min.js** - available.
[UMD](https://github.com/umdjs/umd) bundles for development - **[index.js](lib/index.js)** with sourcemap **[index.js.map](lib/index.js.map)** - and production - **[index.min.js](lib/index.min.js)** - available.

So it's installable both on **node** and/or for **browsers**.
So it's installable both on **node** and/or for **browsers**, with almost every module system existing (e.g. AMD, CJS).

```
$ npm install luhn-alg
Expand Down Expand Up @@ -43,7 +43,7 @@ $ true

### Browsers

Include the UMD build (e.g., **index.min.js**) and you'll have a **luhn** function on the window/global scope.
Include the bundle (e.g., **index.min.js**) and you'll have a **luhn** function on the window/global scope.

Or use CommonJS, AMD, WTFYW etc.

Expand All @@ -52,7 +52,7 @@ Tests

This project is fully unit tested on:

* node.js 0.10, node.js 0.12, io.js
* node.js 0.12, node.js 4, latest node.js stable release
* about 50 [browser versions](https://github.com/leodido/luhn.js/blob/master/.zuul.yml)

Credits
Expand All @@ -63,4 +63,4 @@ Credits

---

[![Analytics](https://ga-beacon.appspot.com/UA-49657176-1/luhn.js)](https://github.com/igrigorik/ga-beacon)
[![Analytics](https://ga-beacon.appspot.com/UA-49657176-1/luhn.js?flat)](https://github.com/igrigorik/ga-beacon)
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "luhn-alg",
"main": "index.js",
"version": "1.0.1",
"main": "lib/index.js",
"version": "1.1.0",
"authors": [
"Leo Di Donato <[email protected]>"
],
Expand Down
28 changes: 0 additions & 28 deletions index.js

This file was deleted.

1 change: 0 additions & 1 deletion index.js.map

This file was deleted.

1 change: 0 additions & 1 deletion index.min.js

This file was deleted.

26 changes: 26 additions & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 43 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "luhn-alg",
"description": "Fastest implementation of the Luhn algorithm",
"version": "1.0.1",
"main": "index.js",
"jsnext:main": "src.js",
"version": "1.1.0",
"main": "lib/index.js",
"jsnext:main": "src/src.js",

This comment has been minimized.

Copy link
@leodido

leodido Apr 18, 2016

Author Owner

Should refer to ES6-module entry point (ready to use, created by prepublish hook).

"author": {
"name": "Leo Di Donato",
"email": "[email protected]",
Expand All @@ -19,26 +19,18 @@
"url": "http://github.com/leodido/luhn.js/issues"
},
"devDependencies": {
"babel": "^5.5.6",
"babel-eslint": "^3.1.15",
"babel-runtime": "^5.5.8",
"babelify": "^6.1.2",
"browserify": "^10.2.4",
"chai": "^3.0.0",
"del": "^1.2.0",
"eslint": "^0.23.0",
"gulp": "gulpjs/gulp.git#4.0",
"gulp-bump": "^0.3.1",
"gulp-cli": "gulpjs/gulp-cli#4.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.5",
"mocha": "^2.2.5",
"phantomjs": "^1.9.17",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"zuul": "^3.0.0"
"babel-eslint": "^5.0.0",
"babel-preset-es2015-rollup": "^1.1.1",
"del-cli": "^0.2.0",
"eslint": "^2.2.0",
"eslint-config-defaults": "^9.0.0",
"estraverse-fb": "^1.3.1",
"mocha": "^2.4.5",
"phantomjs": "^2.1.3",
"rollup": "^0.25.4",
"rollup-plugin-babel": "^2.4.0",
"uglify-js": "^2.6.2",
"zuul": "^3.9.0"
},
"keywords": [
"luhn algorithm",
Expand All @@ -60,10 +52,35 @@
"test": "([ \"${SAUCELABS}\" = true ] && npm run testz) || true",
"testz": "./node_modules/.bin/zuul --no-coverage --concurrency 5 -- test.js",
"testp": "./node_modules/.bin/zuul --phantom -- test.js",
"testl": "./node_modules/.bin/zuul --local 8080 --open -- test.js",
"prepublish": "./node_modules/.bin/gulp production"
"testl": "./node_modules/.bin/zuul --local 8080 --open -- test/*.js",

"lint": "./node_modules/.bin/eslint src/*.js test/*.js",
"clean": "./node_modules/.bin/del-cli lib/",
"prebundle": "npm run clean",
"bundle": "./node_modules/.bin/rollup -c rollup.config.js",
"predist": "npm run bundle",
"dist": "./node_modules/.bin/uglifyjs -c -m -o lib/index.min.js -- lib/index.js",
"prepublish": ""
},
"engines": {
"node": ">=0.10"
"node": ">=0.12"
},
"eslintConfig": {
"extends": "eslint-config-defaults",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"mocha": true
},
"rules": {
"quotes": [
2,
"single"
]
}
}
}
17 changes: 17 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

import babel from 'rollup-plugin-babel';

export default {
entry: 'src/index.js',
format: 'umd',
moduleName: 'luhn',
moduleId: 'luhn',
sourceMap: true,
plugins: [
babel({
exclude: 'node_modules/**'
})
],
dest: 'lib/index.js'
}
3 changes: 3 additions & 0 deletions src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "es2015-rollup" ]
}
8 changes: 5 additions & 3 deletions src.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

export default function(array) {
return function (number) {
const luhn = array => {
return number => {
let len = number ? number.length : 0,
bit = 1,
sum = 0;
Expand All @@ -12,4 +12,6 @@ export default function(array) {

return sum % 10 === 0 && sum > 0;
};
}([0, 2, 4, 6, 8, 1, 3, 5, 7, 9]);
}

export default luhn([0, 2, 4, 6, 8, 1, 3, 5, 7, 9]);
2 changes: 1 addition & 1 deletion test.js → test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

/* global describe:false, it:false */


import { expect } from 'chai';
import luhn from './src';
Expand Down

0 comments on commit f0a124f

Please sign in to comment.