From 5b17371918cd7e469a83077a9e607f8d6c6e8fd9 Mon Sep 17 00:00:00 2001 From: Daniel Arthur Gallagher Date: Fri, 28 Apr 2017 10:25:50 +0100 Subject: [PATCH] App written --- .babelrc | 3 +++ .flowconfig | 0 .npmignore | 2 ++ README.md | 2 ++ flow-typed/jack.js | 1 + lib/jack.js | 14 ++++++++++++++ lib/jack.js.flow | 10 ++++++++++ package.json | 42 ++++++++++++++++++++++++++++++++++++++++++ src/jack.js | 10 ++++++++++ 9 files changed, 84 insertions(+) create mode 100644 .babelrc create mode 100644 .flowconfig create mode 100644 .npmignore create mode 100644 README.md create mode 100644 flow-typed/jack.js create mode 100644 lib/jack.js create mode 100644 lib/jack.js.flow create mode 100644 package.json create mode 100644 src/jack.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c0c1953 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets":["flow", "env"] +} diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..e69de29 diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..5ded421 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +src +README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a9718e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Formal +being in accordance with the usual requirements, customs, etc diff --git a/flow-typed/jack.js b/flow-typed/jack.js new file mode 100644 index 0000000..6aaee2d --- /dev/null +++ b/flow-typed/jack.js @@ -0,0 +1 @@ +declare function preventSubmission(submission: Event, callback?: () => void): void; diff --git a/lib/jack.js b/lib/jack.js new file mode 100644 index 0000000..349b819 --- /dev/null +++ b/lib/jack.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.preventSubmission = preventSubmission; +function preventSubmission(submission, callback) { + submission.preventDefault(); + if (callback) { + callback(); + } else { + return; + } +} \ No newline at end of file diff --git a/lib/jack.js.flow b/lib/jack.js.flow new file mode 100644 index 0000000..d4f1ee0 --- /dev/null +++ b/lib/jack.js.flow @@ -0,0 +1,10 @@ +// @flow + +export function preventSubmission(submission: Event, callback?: () => void): void { + submission.preventDefault(); + if (callback) { + callback(); + } else { + return; + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..158c5eb --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "customary", + "version": "1.0.0", + "description": "Prevents form submission after native validation has taken place.", + "main": "lib/jack.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "flow": "flow", + "build:transpile": "babel src --out-dir lib", + "build:type": "flow-copy-source -v src lib", + "build": "npm run build:transpile && npm run build:type", + "prepublish": "npm run build" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/DanArthurGallagher/formal.git" + }, + "keywords": [ + "front-end" + ], + "author": "Daniel Arthur Gallagher", + "license": "MIT", + "bugs": { + "url": "https://github.com/DanArthurGallagher/formal/issues" + }, + "homepage": "https://github.com/DanArthurGallagher/formal#readme", + "devDependencies": { + "babel-cli": "^6.24.1", + "babel-preset-env": "^1.4.0", + "babel-preset-flow": "^6.23.0", + "flow-bin": "^0.45.0", + "flow-copy-source": "^1.1.0" + }, + "browserslist": [ + "last 2 Chrome versions", + "last 2 Firefox versions", + "last 1 Safari version", + "last 1 iOS version", + "last 1 Samsung version", + "last 1 Edge version" + ] +} diff --git a/src/jack.js b/src/jack.js new file mode 100644 index 0000000..d4f1ee0 --- /dev/null +++ b/src/jack.js @@ -0,0 +1,10 @@ +// @flow + +export function preventSubmission(submission: Event, callback?: () => void): void { + submission.preventDefault(); + if (callback) { + callback(); + } else { + return; + } +}