This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+20
View File
@@ -0,0 +1,20 @@
Copyright Mathias Bynens <http://mathiasbynens.be/>
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.
+47
View File
@@ -0,0 +1,47 @@
# ES6 `String.prototype.codePointAt` polyfill [![Build status](https://travis-ci.org/mathiasbynens/String.prototype.codePointAt.svg?branch=master)](https://travis-ci.org/mathiasbynens/String.prototype.codePointAt)
A robust & optimized ES3-compatible polyfill for [the `String.prototype.codePointAt` method in ECMAScript 6](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.codepointat).
Other polyfills for `String.prototype.codePointAt` are available:
* <http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/#String> by [Norbert Lindenberg](http://norbertlindenberg.com/) (fails some tests)
* <https://gist.github.com/slevithan/2290602> by [Steven Levithan](http://stevenlevithan.com/) (fails some tests)
* <https://github.com/paulmillr/es6-shim/blob/8e570a4b425a80f9b13ff027dbd28d65f201a319/es6-shim.js#L171-L183> by [Paul Miller](http://paulmillr.com/) (~~[fails some tests](https://github.com/paulmillr/es6-shim/issues/166)~~ passes all tests)
## Installation
In a browser:
```html
<script src="codepointat.js"></script>
```
Via [npm](http://npmjs.org/):
```bash
npm install string.prototype.codepointat
```
Then, in [Node.js](http://nodejs.org/):
```js
require('string.prototype.codepointat');
// On Windows and on Mac systems with default settings, case doesnt matter,
// which allows you to do this instead:
require('String.prototype.codePointAt');
```
## Notes
[A polyfill + test suite for `String.fromCodePoint`](http://mths.be/fromcodepoint) is available, too.
## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](http://mathiasbynens.be/) |
## License
This polyfill is available under the [MIT](http://mths.be/mit) license.
+54
View File
@@ -0,0 +1,54 @@
/*! http://mths.be/codepointat v0.2.0 by @mathias */
if (!String.prototype.codePointAt) {
(function() {
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
var defineProperty = (function() {
// IE 8 only supports `Object.defineProperty` on DOM elements
try {
var object = {};
var $defineProperty = Object.defineProperty;
var result = $defineProperty(object, object, object) && $defineProperty;
} catch(error) {}
return result;
}());
var codePointAt = function(position) {
if (this == null) {
throw TypeError();
}
var string = String(this);
var size = string.length;
// `ToInteger`
var index = position ? Number(position) : 0;
if (index != index) { // better `isNaN`
index = 0;
}
// Account for out-of-bounds indices:
if (index < 0 || index >= size) {
return undefined;
}
// Get the first code unit
var first = string.charCodeAt(index);
var second;
if ( // check if its the start of a surrogate pair
first >= 0xD800 && first <= 0xDBFF && // high surrogate
size > index + 1 // there is a next code unit
) {
second = string.charCodeAt(index + 1);
if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
}
}
return first;
};
if (defineProperty) {
defineProperty(String.prototype, 'codePointAt', {
'value': codePointAt,
'configurable': true,
'writable': true
});
} else {
String.prototype.codePointAt = codePointAt;
}
}());
}
+97
View File
@@ -0,0 +1,97 @@
{
"_args": [
[
{
"raw": "string.prototype.codepointat@^0.2.0",
"scope": null,
"escapedName": "string.prototype.codepointat",
"name": "string.prototype.codepointat",
"rawSpec": "^0.2.0",
"spec": ">=0.2.0 <0.3.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\node-emoji"
]
],
"_from": "string.prototype.codepointat@>=0.2.0 <0.3.0",
"_id": "string.prototype.codepointat@0.2.0",
"_inCache": true,
"_location": "/string.prototype.codepointat",
"_npmUser": {
"name": "mathias",
"email": "mathias@qiwi.be"
},
"_npmVersion": "1.4.3",
"_phantomChildren": {},
"_requested": {
"raw": "string.prototype.codepointat@^0.2.0",
"scope": null,
"escapedName": "string.prototype.codepointat",
"name": "string.prototype.codepointat",
"rawSpec": "^0.2.0",
"spec": ">=0.2.0 <0.3.0",
"type": "range"
},
"_requiredBy": [
"/node-emoji"
],
"_resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz",
"_shasum": "6b26e9bd3afcaa7be3b4269b526de1b82000ac78",
"_shrinkwrap": null,
"_spec": "string.prototype.codepointat@^0.2.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\node-emoji",
"author": {
"name": "Mathias Bynens",
"url": "http://mathiasbynens.be/"
},
"bugs": {
"url": "https://github.com/mathiasbynens/String.prototype.codePointAt/issues"
},
"dependencies": {},
"description": "A robust & optimized `String.prototype.codePointAt` polyfill, based on the ECMAScript 6 specification.",
"devDependencies": {},
"directories": {
"test": "tests"
},
"dist": {
"shasum": "6b26e9bd3afcaa7be3b4269b526de1b82000ac78",
"tarball": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz"
},
"files": [
"LICENSE-MIT.txt",
"codepointat.js"
],
"homepage": "http://mths.be/codepointat",
"keywords": [
"string",
"unicode",
"es6",
"ecmascript",
"polyfill"
],
"licenses": [
{
"type": "MIT",
"url": "http://mths.be/mit"
}
],
"main": "codepointat.js",
"maintainers": [
{
"name": "mathias",
"email": "mathias@qiwi.be"
}
],
"name": "string.prototype.codepointat",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/mathiasbynens/String.prototype.codePointAt.git"
},
"scripts": {
"cover": "istanbul cover --report html --verbose --dir coverage tests/tests.js",
"test": "node tests/tests.js"
},
"version": "0.2.0"
}