Skip to content

Commit

Permalink
WIP (add travis)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviervia committed Aug 3, 2017
1 parent 0b111f8 commit 4bc2ce2
Show file tree
Hide file tree
Showing 6 changed files with 2,783 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
["env", {
"targets": {
"browsers": [
"last 2 versions",
"IE >= 9"
]
}
}]
]
}
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js
node_js:
- '7'
before_script:
- npm install
script:
- npm test
deploy:
provider: npm
email: [email protected]
api_key:
secure: rm+EaAEFArhvOJhXPSmesp6oH2IRe4+xovWhLa9c8IH5eE3sBmwVd8JmrHRwZQqF3Z2m6EHgNFMJyWAt76UL+4oineyXc3ju+JBGzLZcVqGiAkLz48+LJqHWsenzHn+BAlAFzCYBKCbUtaYl7l68IZZ6krin74NhQkgs//w6GKxng446LncyUU4qQBVzWabR//iYqpjFYvEhPHBCSicjWYzHcm7v+6/kqZJbJxxllGbdA3U8R1wgj79S5bNNC8ylVZKNnGCFcOeg0avXMRNAvlNKRmW41IVv+1cPYh9nTkVBbeW3FYn8xo7Fv39zulDHP1YEfp9tu0N7i5ni7C4spIjHAxrTp9H4ddJ7k15tr2AQwTgIcqwtPH3Xx9Q1JU5bgRrr9shTEd5+x+Tz6Hd00Df6Os2C6huiN/renpaJa/61kowvIXNYNmUMN2M3dptl0y46SaDSlSV3jqK5yyWq/21e9R1FldbcJnRzdv3vksKE3nWp/cqXWx3vbPMeWUjfTvT9K9Le6ZhwHw7g0sReX+9rhFEkMo5ATlaaiw4dGnM7WGSZs1IRNtCYaYKrInT1rLYq0f4gBaNoRD9Ef4yzKrRg4jNFv7W4T6HC7UaNnFizWCZc8pMrD6F1VHHUVJDQBra+ZjgxQyndHQnCDze70oihhpdiEI2gXyguqaABBd8=
on:
tags: true
repo: batata-frita/vybor
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "vybor",
"version": "0.1.2",
"description": "Function to choose. Like `switch`, but you don't need an IIFE",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"dist": "babel src/ -d dist/",
"test": "jest",
"prepare": "npm test && npm run dist"
},
"repository": {
"type": "git",
"url": "git+https://github.com/batata-frita/vybor.git"
},
"keywords": [],
"constributors": [
"Kir Belevich <[email protected]> (https://github.com/deepsweet)",
"Xavier Via <[email protected]> (http://github.com/xaviervia)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/batata-frita/vybor/issues"
},
"homepage": "https://github.com/batata-frita/vybor#readme",
"devDependencies": {
"babel-cli": "^6.24.1",
"jest": "^20.0.4",
"babel-preset-env": "^1.6.0"
}
}
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const выбор = (...args) => {
if (args.length > 0) {
if (args[0] === true) {
return args[1]
}

return выбор(...args.slice(2))
}
}

export default выбор
20 changes: 20 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import выбор from '../src'
import {equal} from 'assert'

describe('выбор', () => {
it('returns the successor of the closest match', () => {
equal(выбор('two')(
'one', 1,
'two', 2,
'three', 3
), 2)
})

it('returns undefined if nothing is matched', () => {
equal(выбор('four')(
'one', 1,
'two', 2,
'three', 3
), undefined)
})
})
Loading

0 comments on commit 4bc2ce2

Please sign in to comment.