olivernn / augment.js Goto Github PK
View Code? Open in Web Editor NEWModern JavaScript in your IE
Home Page: https://olivernn.github.io/augment.js/
License: MIT License
Modern JavaScript in your IE
Home Page: https://olivernn.github.io/augment.js/
License: MIT License
As described here Mozila doc, there's a method string.includes to check whether a string contains searchString or not.
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
We should also add this in augment.js
https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute
Documented there. See es5-shim for fix.
I love the intention of the library but was wondering if there was a good reason not to include the Object.create method as implemented here:
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create
Only adds 10 LOC: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create
Or was there a reason to exclude it? There are Object extensions already, so...
bound = function () {
return self.apply( nop.prototype && this instanceof nop ? this : ( obj || {} ),
args.concat( slice.call(arguments) ) );
};
http://es5.github.com/#x15.3.4.5
Set the [[Construct]] internal property of F as described in 15.3.4.5.2.
http://es5.github.com/#x15.3.4.5.2
Return the result of calling the [[Construct]] internal method oftarget providing args as the arguments.
http://es5.github.com/#x13.2.2
Return obj.
Basically your code always returns the return value of the bound function and doesn't handle cases like
new ( (function () {
return undefined;
}).bind(lulz, args) ) !== undefined;
Here the return value of invoking new
(and [[Construct]]
) on the bound function should be that the new instance is returned, not the return value of the bound function.
Again see es5-shim for implementation.
See shim :
http://forrst.com/posts/Object_getPrototypeOf_shim-eNB
It might be worthwhile to add this to augment.
The docs site is down.
https://gist.github.com/1120592
Lists a bunch of bugs that are in various implementations of ES5 shims. You may want to thoroughly check yours does not fail any.
For example
String#trim
using buggy character class \s instead of explicitly defining whitespace/line terminators
Note that \s
fails in IE sometimes (because IE, rage.)
Following the argumentation and the benchmarks of http://blog.stevenlevithan.com/archives/faster-trim-javascript I suggest to use the trim implementation from there.
Extended Years not supported by Date.prototype.toISOString
AKA do we need both projects?
just curious as I don't know which project to recommend.
Thank you :)
Right now augment.string.trim.js removes all the whitespace, instead of just the beginning and the end. I think the proper implementation should be more along these lines: https://gist.github.com/973478
Object.create is that much used now but certainly it is important to have i think - checkout: http://javascript.crockford.com/prototypal.html . Also in this bundle may be provided JSON.parse and JSON.stringify for completeness.
Regards,
Daniel
P.S. i'm not a ruby dev so it's hard for me to just send you pull request for those
It should be easier to build a stripped down subset of augment, including only the methods that you want to polyfill.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.