Skip to content

Commit

Permalink
Merge branch 'total-rework' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zerobias committed Dec 29, 2016
2 parents e4d5765 + 4df2138 commit 39e6379
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 75 deletions.
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugins": [
"transform-es2015-block-scoping",
"transform-es2015-parameters"
]
}
142 changes: 122 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,138 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"extends": [
"standard",
"eslint:recommended"
],
"plugins": [],
"plugins": [
"babel",
"promise"
],
"env": {
"browser" : true,
"node": true,
"es6": true
"node" : true,
"browser": false,
"es6" : true
},
"rules": {
"key-spacing" : 0,
"no-console" : 0,
"no-extra-semi" : 2,
"no-unused-vars": "warn",
"no-redeclare": "warn",
"no-undef": "error",
"no-console" : "off",

//Controversial rules
"no-unused-vars" : "warn",
"prefer-template" : "warn",
"no-nested-ternary" : "warn",
"no-unneeded-ternary" : "warn",
"no-underscore-dangle" : "warn",
"prefer-const" : "warn",
"no-constant-condition": "off",

//General
"arrow-body-style" : ["error", "as-needed"],
"no-var" : "error",
"no-duplicate-imports" : "error",

//Style rules. Freely varies according to projects
"quotes" : ["error", "single",{
"allowTemplateLiterals": true,
"avoidEscape": true
}],
"max-len" : ["error", {
"code": 120,
"tabWidth":2,
"comments":120 //Separated max length for comments
}],

//Indents,whitespace settings
"key-spacing" : ["warn", {
"singleLine":{
"beforeColon": false,
"afterColon": true
},
"multiLine": {
"align": {
"beforeColon": false,
"afterColon": true,
"on": "colon",
"mode": "strict"
}
}
}],
"comma-spacing" : ["error", {
"before": false,
"after": true
}],
"object-curly-spacing" : [2, "always"],
"semi-spacing" : ["error", {
"before": false,
"after": true
}],
"indent" : [1,2,{
"VariableDeclarator" : {
"var": 2,
"let": 2,
"const": 3 },
"var" : 2,
"let" : 2,
"const" : 3
},
"FunctionDeclaration": {
"parameters": "first"},
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"},
"parameters": "first"
},
"MemberExpression": 1,
"SwitchCase": 1}],
"max-len" : [2, 120, 2],
"object-curly-spacing" : [2, "always"]
"SwitchCase": 1
}],
"multiline-ternary" : ["warn", "always"],
"operator-linebreak": ["error", "after", {
"overrides": {
"?": "before",
":": "before"
}
}],
"newline-per-chained-call": ["error", {
"ignoreChainWithDepth": 2
}],
"keyword-spacing": ["error", { "before": true }],
"space-unary-ops": ["error", {
"words": true,
"nonwords": false
}],
"no-whitespace-before-property": "error",
"generator-star-spacing": ["error", {
"before": false,
"after": true
}],
"arrow-spacing": ["error", {
"before": true,
"after": true
}],
"space-before-function-paren": ["error", "never"],
"rest-spread-spacing" : ["error", "never"],

//Strict best practices. No reason not to use this
"no-alert" : "error",
"no-bitwise" : "error",
"no-caller" : "error",
"no-global-assign" : "error",
"no-eval" : "error",
"no-implied-eval" : "error",
"no-proto" : "error",
"no-iterator" : "error",
"no-lone-blocks" : "error",
"no-self-compare" : "error",
"no-invalid-regexp" : ["error", {
"allowConstructorFlags": ["u", "y"]
}],
"no-with" : "error",
"no-new-func" : "error",
"prefer-spread" : "error",
//Unnecessary semicolon is an annoying visual clutter
"no-extra-semi" : "error",
"semi" : ["error", "never"]
}
}

// https://github.com/zerobias
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dist
es
lib
.coveralls.yml

typings.json
.idea/
30 changes: 15 additions & 15 deletions ensue.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
"use strict";
'use strict'
const R = require('ramda')
const test = require('tap').test

const unit = require('./lib/index')
const unit = require('./src/index')

const funcCompare = ref => func => R.converge(R.equals,[ref,func])
const funcCompare = ref => func => R.converge(R.equals, [ref, func])

test('smoke test',function(t){
const isFunc = (obj,text) => t.is(R.is(Function,obj),true,text)
isFunc(unit,'Pipefy exists')
test('smoke test', function(t){
const isFunc = (obj, text) => t.is(R.is(Function, obj), true, text)
isFunc(unit, 'Pipefy exists')
t.end()
})

test('pipelining',function(t){
test('pipelining', function(t){
const steps = {
a:R.when(R.equals(0),()=>10),
b:R.add(10),
c:R.add(100)
a: R.when(R.equals(0), () => 10),
b: R.add(10),
c: R.add(100)
}
const refer = R.pipe(steps.a,steps.b,steps.c)
const refer = R.pipe(steps.a, steps.b, steps.c)
const testVal = 0
const comp = funcCompare(refer)
let pipe
t.notThrow(()=>pipe=unit(steps.a,steps.b,steps.c),'pipeline accept pipe as args')
t.equals(comp(pipe)(testVal),true,'Works as referenced R.pipe')
t.notThrow(()=>pipe=unit([steps.a,steps.b,steps.c]),'pipeline accept pipe as array')
t.equals(comp(pipe)(testVal),true,'Pipe from array works as referenced R.pipe')
t.notThrow(() => pipe=unit(steps.a, steps.b, steps.c), 'pipeline accept pipe as args')
t.equals(comp(pipe)(testVal), true, 'Works as referenced R.pipe')
t.notThrow(() => pipe=unit([steps.a, steps.b, steps.c]), 'pipeline accept pipe as array')
t.equals(comp(pipe)(testVal), true, 'Pipe from array works as referenced R.pipe')
t.end()
})
21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
{
"name": "ensue",
"version": "1.1.1",
"version": "2.0.1-beta.0",
"description": "Function sequence (pipe) with nested arrays of sequences",
"main": "lib/index.js",
"jsnext:main": "es/index.js",
"module": "es/index.js",
"main": "src/index.js",
"browser": "dist/index.js",
"scripts": {
"pretest": "npm run build:cjs",
"test": "tap ensue.test.js --100",
"coverage:html": "nyc --coverage-report=html npm test",
"coverage": "nyc -r=text -r=lcov tap ensue.test.js",
"coveralls": "nyc report --reporter=text-lcov tap ensue.test.js | coveralls",
"clean": "rimraf es & rimraf lib & rimraf dist",
"prepublish": "npm run build",
"postpublish": "npm run clean",
"build:cjs": "rollup -c",
"build:umd": "rollup -c",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "rollup -c --environment BUILD:umd",
"build": "npm run build:es && npm run build:cjs && npm run build:umd"
"build": "npm run build:umd"
},
"files": [
"dist",
"lib",
"es",
"src/index.js"
"src/index.js",
"dist/index.js"
],
"keywords": [
"fp",
Expand All @@ -42,7 +36,7 @@
"author": "Zero Bias",
"license": "MIT",
"dependencies": {
"ramda": "^0.22.1"
"array-flatten": "^2.1.0"
},
"devDependencies": {
"babel-cli": "^6.16.0",
Expand All @@ -51,6 +45,7 @@
"coveralls": "^2.11.14",
"cross-env": "^3.1.3",
"nyc": "^8.3.0",
"ramda": "^0.22.1",
"rollup": "^0.36.1",
"rollup-plugin-cleanup": "^0.1.4",
"rollup-plugin-commonjs": "^5.0.4",
Expand Down
54 changes: 33 additions & 21 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,54 @@ import cleanup from 'rollup-plugin-cleanup'
// import uglify from 'rollup-plugin-uglify'
// import { minify } from 'uglify-js'

let pkg = require('./package.json')
let external = Object.keys(pkg.dependencies)
const pkg = require('./package.json')
const external = Object.keys(pkg.dependencies)

const isUmd = process.env.BUILD === 'umd'
// const isUmd = process.env.BUILD === 'umd'

const builds = {
cmj : pkg.main,
es : pkg.module,
umd : pkg.browser
cjs: pkg.main,
es : pkg.module,
umd: pkg.browser
}

const target = [{
dest: isUmd?builds.umd:builds.cmj,
format: isUmd?'umd':'cjs',
moduleName: 'ensue',
sourceMap: true
}]
const targets = {
commonjs: {
dest : builds.cjs, //WARN~! Overwrite source file!
format : 'cjs',
moduleName : 'ensue',
sourceMap : true,
preferConst: true
},
umd: {
dest : builds.umd,
format : 'umd',
moduleName: 'ensue',
sourceMap : 'inline'
}
}

const target = [ targets.umd ]
const plugins = [
cleanup(),
nodeResolve({
jsnext: true,
main: false,
module: true,
skip: true,
jsnext : true,
main : false,
module : true,
skip : true,
preferBuiltins: false
}),
commonjs({
include: ['src/index.js']
})
]
export default {
entry:'es/index.js',
entry : 'src/index.js',
globals: {
"ramda": "R"
'array-flatten': 'flatten'
},
plugins: plugins,
external: external,
targets: target
preferConst: true,
plugins : plugins,
external : external,
targets : target
}
Loading

0 comments on commit 39e6379

Please sign in to comment.