From 25e0a1386eed53dceb98e802e473b4ae22f3e764 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 26 Jan 2017 16:11:31 +0700 Subject: [PATCH] Initial commit --- .gitignore | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 7 +++++ LICENSE | 21 +++++++++++++++ README.md | 17 ++++++++++++ dist/index.js | 40 ++++++++++++++++++++++++++++ package.json | 39 ++++++++++++++++++++++++++++ src/index.js | 3 +++ test/types.js | 6 +++++ 8 files changed, 205 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 dist/index.js create mode 100644 package.json create mode 100644 src/index.js create mode 100644 test/types.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..635b656 --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +## Node + +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# 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 directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +## OS X + +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d8b251d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: node +script: npm run lint && npm test +after_success: npm run coverage +notifications: + email: + on_success: never diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e2db8f2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Luke Childs + +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.md b/README.md new file mode 100644 index 0000000..255d7f6 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# merge-images + +> Easily compose images together without messing around in canvas + +[![Build Status](https://travis-ci.org/lukechilds/merge-images.svg?branch=master)](https://travis-ci.org/lukechilds/merge-images) +[![Coverage Status](https://coveralls.io/repos/github/lukechilds/merge-images/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/merge-images?branch=master) +[![npm](https://img.shields.io/npm/v/merge-images.svg)](https://www.npmjs.com/package/merge-images) + +## Install + +```shell +npm install --save merge-images +``` + +## License + +MIT © Luke Childs diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..45a97c8 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,40 @@ +// Loaded ready states +const loadedStates = ['interactive', 'complete']; + +// Return Promise +const whenDomReady = function (cb, doc) { + return new Promise(function (resolve) { + // Allow doc to be passed in as the lone first param + if (cb && typeof cb !== 'function') { + doc = cb; + cb = null; + } + + // Use global document if we don't have one + doc = doc || window.document; + + // Handle DOM load + const done = function () { + return resolve(cb && cb()); + }; + + // Resolve now if DOM has already loaded + // Otherwise wait for DOMContentLoaded + if (loadedStates.indexOf(doc.readyState) !== -1) { + setTimeout(done, 0); + } else { + doc.addEventListener('DOMContentLoaded', done); + } + }); +}; + +// Promise chain helper +whenDomReady.resume = function (doc) { + return function (val) { + return whenDomReady(doc).then(function () { + return val; + }); + }; +}; + +module.exports = whenDomReady; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..d5acc40 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "merge-images", + "version": "0.0.0", + "description": "Easily compose images together without messing around in canvas", + "main": "src/index.js", + "scripts": { + "lint": "xo", + "test": "nyc ava", + "coverage": "nyc report --reporter=text-lcov | coveralls" + }, + "xo": { + "env": "browser" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/lukechilds/merge-images.git" + }, + "keywords": [ + "compose", + "merge", + "images", + "without", + "no", + "canvas" + ], + "author": "Luke Childs (http://lukechilds.co.uk)", + "license": "MIT", + "bugs": { + "url": "https://github.com/lukechilds/merge-images/issues" + }, + "homepage": "https://github.com/lukechilds/merge-images", + "dependencies": {}, + "devDependencies": { + "ava": "^0.17.0", + "coveralls": "^2.11.15", + "nyc": "^10.0.0", + "xo": "^0.17.1" + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..1bf7157 --- /dev/null +++ b/src/index.js @@ -0,0 +1,3 @@ +const imageMerge = () => true; + +module.exports = imageMerge; diff --git a/test/types.js b/test/types.js new file mode 100644 index 0000000..4f93d90 --- /dev/null +++ b/test/types.js @@ -0,0 +1,6 @@ +import test from 'ava'; +import mergeImages from '../'; + +test('mergeImages is a function', t => { + t.is(typeof mergeImages, 'function'); +});