From b82c32a06d457edfa7e2677b58451d1cceb5176e Mon Sep 17 00:00:00 2001 From: hemanth Date: Wed, 15 Apr 2015 07:23:47 +0000 Subject: [PATCH] init0 --- .editorconfig | 12 +++++++++ .gitignore | 57 +++++++++++++++++++++++++++++++++++++++++++ .jshintrc | 29 ++++++++++++++++++++++ .travis.yml | 6 +++++ CONTRIBUTING.markdown | 15 ++++++++++++ LICENSE | 23 +++++++++++++++++ README.markdown | 26 ++++++++++++++++++++ gulpfile.js | 31 +++++++++++++++++++++++ index.es6 | 8 ++++++ index.js | 9 +++++++ package.json | 39 +++++++++++++++++++++++++++++ test.es6 | 6 +++++ test.js | 16 ++++++++++++ 13 files changed, 277 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.markdown create mode 100644 LICENSE create mode 100644 README.markdown create mode 100644 gulpfile.js create mode 100644 index.es6 create mode 100644 index.js create mode 100644 package.json create mode 100644 test.es6 create mode 100644 test.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5c2af09 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +charset = utf-8 + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46dbba4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +#### joe made this: https://goel.io/joe + +#####=== Node ===##### + +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Debug log from npm +npm-debug.log + +#####=== OSX ===##### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..1960c76 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,29 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "immed": true, + "latedef": "nofunc", + "newcap": false, + "noarg": true, + "undef": true, + "strict": false, + "trailing": true, + "smarttabs": true, + "indent": 2, + "white": false, + "quotmark": "single", + "laxbreak": true, + "globals" : { + "describe" : false, + "expect" : false, + "it" : false, + "before" : false, + "beforeEach" : false, + "after" : false, + "afterEach" : false + } +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..453adf9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" +node_js: + - '0.10' diff --git a/CONTRIBUTING.markdown b/CONTRIBUTING.markdown new file mode 100644 index 0000000..c78e694 --- /dev/null +++ b/CONTRIBUTING.markdown @@ -0,0 +1,15 @@ +# Contributing + +- Always add tests +- Update documentation if needed +- run `gulp test` before submitting + +## Bug fixes + +Always add a test for the bug in a separate commit so we can easily cherry pick +it for verification. + +## New features + +It's recommended to open an issue before sending a pull request to avoid +unnecessary work. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d94c28b --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2015 hemanth.hm +Copyright (c) 2015 stoeffel + +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. + diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..3bbe3ea --- /dev/null +++ b/README.markdown @@ -0,0 +1,26 @@ +# fj-apply + +[![Build Status](https://travis-ci.org/fp-js/fj-apply.svg)](https://travis-ci.org/fp-js/fj-apply) [![npm version](https://badge.fury.io/js/fj-apply.svg)](http://badge.fury.io/js/fj-apply) +> `apply` in functional style! + + +## Installation + +`npm install fj-apply --save` + +## Usage + +```js +var apply = require('fj-apply'); +apply(Math.min,[-1,1,2,42,0]); // -1 +``` + +## API + +``` +(*... -> a) -> [*]-> a +``` + +* `fn` (madatory) function to applied. + +* `arg` (madatory) arguments with which `fn` should be called. diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e390d1e --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,31 @@ +var gulp = require('gulp'), + watch = require('gulp-watch'), + run = require('gulp-run'), + sourcemaps = require('gulp-sourcemaps'), + rename = require('gulp-rename'), + mochify = require('mochify'), + to5 = require('gulp-babel'); + +gulp.task('babel', function() { + return gulp.src('**/*.es6') + .pipe(sourcemaps.init()) + .pipe(to5({ + stage: 0, + loose: 'all' + })) + .pipe(sourcemaps.write()) + .pipe(rename({ + extname: '.js' + })) + .pipe(gulp.dest('./')); +}); + +gulp.task('test', ['babel'], function() { + mochify('./test.js', { + reporter: 'tap' + }).bundle(); +}); + +gulp.task('default', ['test'], function() { + gulp.watch('**/*.es6', ['test']); +}); diff --git a/index.es6 b/index.es6 new file mode 100644 index 0000000..c8909c3 --- /dev/null +++ b/index.es6 @@ -0,0 +1,8 @@ +import {curry2} from 'fj-curry'; + +// Don't use arrow function here. +var _apply = function (fn, args) { + return fn.apply(this, args); +} + +module.exports = curry2(_apply); diff --git a/index.js b/index.js new file mode 100644 index 0000000..5e00420 --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +'use strict'; + +var _curry2 = require('fj-curry'); + +var _apply = function _apply(fn, args) { + return fn.apply(undefined, args); +}; +module.exports = _curry2.curry2(_apply); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmVzNiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztzQkFBcUIsVUFBVTs7QUFFL0IsSUFBSSxNQUFNLEdBQUcsZ0JBQUMsRUFBRSxFQUFFLElBQUksRUFBSztBQUN6QixTQUFPLEVBQUUsQ0FBQyxLQUFLLFlBQU8sSUFBSSxDQUFDLENBQUM7Q0FDN0IsQ0FBQTtBQUNELE1BQU0sQ0FBQyxPQUFPLEdBQUcsUUFMVCxNQUFNLENBS1UsTUFBTSxDQUFDLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQge2N1cnJ5Mn0gZnJvbSAnZmotY3VycnknO1xuXG52YXIgX2FwcGx5ID0gKGZuLCBhcmdzKSA9PiB7XG4gIHJldHVybiBmbi5hcHBseSh0aGlzLCBhcmdzKTtcbn1cbm1vZHVsZS5leHBvcnRzID0gY3VycnkyKF9hcHBseSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ce5c597 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "fj-apply", + "version": "0.0.0", + "description": "`apply` in functional style!", + "main": "index.js", + "scripts": { + "test": "gulp test" + }, + "repository": { + "type": "git", + "url": "https://github.com/fp-js/fj-apply.git" + }, + "keywords": [ + "fp-dom", + "fp", + "dom" + ], + "contributors": [ + "hemanth.hm (http://www.h3manth.com)", + "stoeffel (http://www.schtoeffel.ch)" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/fp-js/fj-apply/issues" + }, + "homepage": "https://github.com/fp-js/fj-apply", + "devDependencies": { + "gulp": "^3.8.10", + "gulp-rename": "^1.2.0", + "gulp-babel": "^5.0.0", + "gulp-run": "^1.6.6", + "gulp-sourcemaps": "^1.3.0", + "gulp-watch": "^4.1.0", + "mochify": "^2.2.0" + }, + "dependencies": { + "fj-curry": "^1.0.0" + } +} diff --git a/test.es6 b/test.es6 new file mode 100644 index 0000000..0b770ba --- /dev/null +++ b/test.es6 @@ -0,0 +1,6 @@ +import assert from 'assert'; +import apply from './'; + +it('fj-apply', () => { + assert.equal(apply(Math.min, [-1,1,0,2,42]), -1); +}); diff --git a/test.js b/test.js new file mode 100644 index 0000000..c04f576 --- /dev/null +++ b/test.js @@ -0,0 +1,16 @@ +'use strict'; + +var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _assert = require('assert'); + +var _assert2 = _interopRequireWildcard(_assert); + +var _apply = require('./'); + +var _apply2 = _interopRequireWildcard(_apply); + +it('fj-apply', function () { + _assert2['default'].equal(_apply2['default'](Math.min, [-1, 1, 0, 2, 42]), -1); +}); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZXM2Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7c0JBQW1CLFFBQVE7Ozs7cUJBQ1QsSUFBSTs7OztBQUd0QixFQUFFLENBQUMsVUFBVSxFQUFFLFlBQU07QUFDbkIsc0JBQU8sS0FBSyxDQUFDLG1CQUFNLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFDLENBQUMsRUFBQyxDQUFDLEVBQUMsQ0FBQyxFQUFDLENBQUMsRUFBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUM7Q0FDbEQsQ0FBQyxDQUFDIiwiZmlsZSI6InRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgYXNzZXJ0IGZyb20gJ2Fzc2VydCc7XG5pbXBvcnQgYXBwbHkgZnJvbSAnLi8nO1xuXG5cbml0KCdmai1hcHBseScsICgpID0+IHtcbiAgYXNzZXJ0LmVxdWFsKGFwcGx5KE1hdGgubWluLCBbLTEsMSwwLDIsNDJdKSwgLTEpO1xufSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= \ No newline at end of file