[Pkg-javascript-commits] [node-has-cors] 01/04: Import Upstream version 1.1.0

Paolo Greppi paolog-guest at moszumanska.debian.org
Thu Dec 15 14:16:30 UTC 2016


This is an automated email from the git hooks/post-receive script.

paolog-guest pushed a commit to branch master
in repository node-has-cors.

commit 030b22ef43c9b3a16cc40001f3dafdb43b1ba40d
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date:   Thu Dec 15 10:17:38 2016 +0000

    Import Upstream version 1.1.0
---
 .gitignore     |  3 +++
 History.md     | 21 +++++++++++++++++++++
 Makefile       | 11 +++++++++++
 Readme.md      | 24 ++++++++++++++++++++++++
 component.json | 13 +++++++++++++
 index.js       | 17 +++++++++++++++++
 package.json   | 32 ++++++++++++++++++++++++++++++++
 test.js        | 24 ++++++++++++++++++++++++
 8 files changed, 145 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..665aa21
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+components
+build
+node_modules
diff --git a/History.md b/History.md
new file mode 100644
index 0000000..4308161
--- /dev/null
+++ b/History.md
@@ -0,0 +1,21 @@
+
+1.1.0 / 2014-11-12
+==================
+
+  * remove "global" module dependency (#2, @achingbrain)
+
+1.0.2 / 2013-08-27
+==================
+
+  * explicitly use `global` instead of being implicit
+  * pin "component/global" to v2.0.1
+
+1.0.1 / 2013-08-23
+==================
+
+  * package: add "component" section
+
+1.0.0 / 2013-08-22
+==================
+
+  * Initial release
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0f14dac
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+
+build: components index.js
+	@component build --dev
+
+components: component.json
+	@component install --dev
+
+clean:
+	rm -fr build components template.js
+
+.PHONY: clean
diff --git a/Readme.md b/Readme.md
new file mode 100644
index 0000000..8954646
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,24 @@
+
+# has-cors
+
+  Detects support for Cross-Origin Resource Sharing
+
+## Installation
+
+  Install with [component(1)](http://component.io):
+
+    $ component install component/has-cors
+
+## API
+
+Exports `true` if the user-agent supports CORS, or `false` otherwise.
+
+``` js
+var hasCORS = require('has-cors');
+console.log(hasCORS);
+// true
+```
+
+## License
+
+  MIT
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..b95e04d
--- /dev/null
+++ b/component.json
@@ -0,0 +1,13 @@
+{
+  "name": "has-cors",
+  "repo": "component/has-cors",
+  "description": "Detects support for Cross-Origin Resource Sharing",
+  "version": "1.1.0",
+  "keywords": [],
+  "development": {},
+  "license": "MIT",
+  "main": "index.js",
+  "scripts": [
+    "index.js"
+  ]
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..952a7c8
--- /dev/null
+++ b/index.js
@@ -0,0 +1,17 @@
+
+/**
+ * Module exports.
+ *
+ * Logic borrowed from Modernizr:
+ *
+ *   - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
+ */
+
+try {
+  module.exports = typeof XMLHttpRequest !== 'undefined' &&
+    'withCredentials' in new XMLHttpRequest();
+} catch (err) {
+  // if XMLHttp support is disabled in IE then it will throw
+  // when trying to create
+  module.exports = false;
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..cd44ed8
--- /dev/null
+++ b/package.json
@@ -0,0 +1,32 @@
+{
+  "name": "has-cors",
+  "version": "1.1.0",
+  "description": "Detects support for Cross-Origin Resource Sharing",
+  "main": "index.js",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/component/has-cors.git"
+  },
+  "keywords": [
+    "cors",
+    "cross",
+    "origin",
+    "resource",
+    "sharing",
+    "domain"
+  ],
+  "author": "Nathan Rajlich <nathan at tootallnate.net> (http://n8.io/)",
+  "license": "MIT",
+  "component": {
+    "scripts": {
+      "has-cors/index.js": "index.js"
+    }
+  },
+  "devDependencies": {
+    "mocha": "^2.0",
+    "chai": "^1.10"
+  },
+  "scripts": {
+    "test": "mocha"
+  }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..d2dfb84
--- /dev/null
+++ b/test.js
@@ -0,0 +1,24 @@
+var expect = require('chai').expect;
+
+describe('has-cors', function() {
+  beforeEach(function() {
+    // make sure result is not cached
+    delete require.cache[require.resolve('./')];
+  });
+  
+  it('should not have cors', function() {
+    var hasCors = require('./');
+
+    expect(hasCors).to.be.false;
+  });
+  
+  it('should have cors', function() {
+    global.XMLHttpRequest = function() {
+      this.withCredentials = true;
+    };
+
+    var hasCors = require('./');
+
+    expect(hasCors).to.be.true;
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-has-cors.git



More information about the Pkg-javascript-commits mailing list