From 652a73095ec4598e720abd3f4ab01b4108dd962d Mon Sep 17 00:00:00 2001 From: Johan Halse Date: Tue, 7 May 2019 11:31:30 +0200 Subject: [PATCH 1/2] Security version bump --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a448960..b1d04b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1444,9 +1444,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.2.tgz", - "integrity": "sha512-QHn/Lh/7HhZ/Twc7vJYQTkjuCa0kaCcDcjK5Zlk2rvnUpy7DxMJ23+Jc2dcyvltwQVg1nygAVlB2oRDFHoRS5Q==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", From 957556bbb0dbd598018c231017efd59f66b77499 Mon Sep 17 00:00:00 2001 From: Johan Halse Date: Tue, 7 May 2019 12:25:26 +0200 Subject: [PATCH 2/2] Adds export functionality for webpack --- README.md | 19 ++++++++++++++++++- package.json | 5 +++++ src/tiny-autocomplete.js | 11 ++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aa3f347..f24c885 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,24 @@ Note: while you can use Tiny Autocomplete with a local data source, the pattern ## Installation -Just include tiny-autocomplete.js after Zepto or jQuery. Include tiny-autocomplete.css and you're good to go! +### Global installation + +If you're not using any package managers, put tiny-autocomplete.js after Zepto or jQuery, include tiny-autocomplete.css, and you're good to go! + +### Installing through npm + +If you're using npm to manage your dependencies, first install the tiny-autocomplete module: + +```javascript +npm install -s @varvet/tiny-autocomplete +``` + +Then require it in your files and activate it after your jQuery or Zepto library, like so: + +```javascript +var $ = require("jquery"); +require("@varvet/tiny-autocomplete")($, window); +``` ## Demos diff --git a/package.json b/package.json index 90354e6..12bbc0f 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,11 @@ "keywords": [ "jquery", "zepto", + "search-as-you-type", + "jquery-plugin", + "ecosystem:jquery", + "zepto-plugin", + "ecosystem:zepto", "autocomplete", "plugin", "extensible" diff --git a/src/tiny-autocomplete.js b/src/tiny-autocomplete.js index ad8d0b1..8c6e0f2 100644 --- a/src/tiny-autocomplete.js +++ b/src/tiny-autocomplete.js @@ -8,7 +8,8 @@ * @version 1.0.0 * @return {object} Self */ -(function(window, $) { + +var factory = function($, window) { var TinyAutocomplete = function(el, options) { var that = this; // This is just to minify better that.field = $(el); @@ -668,6 +669,10 @@ this.tinyAutocomplete = { settings: d.settings }; }); }; +}; - $.tinyAutocomplete = TinyAutocomplete; -})(window, $); +if (typeof exports !== "undefined") { + module.exports = factory; +} else { + factory($, window); +}