ollym / toolkit Goto Github PK
View Code? Open in Web Editor NEWExtends built-in native object methods and brings ECMA5 to legacy browsers.
Home Page: jstoolkit.org
Extends built-in native object methods and brings ECMA5 to legacy browsers.
Home Page: jstoolkit.org
I plan to change these or remove them altogether for 2.0.0
Object.defineProperties() should be used instead.
I really miss enumerable flags/bit masks from C#. Something like:
var enum = new Enum('a', 'b', 'c', 'd');
var mask = enum.a | enum.b;
if (mask & enum.a) // true
if (mask & enum.c) // false
if (mask & enum.b) // true
See https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators#section_13 for some examples.
From Ruby:
center, chars, chomp, concat, count, delete, dump, insert, reverse
From PHP:
ucfirst
From Me:
soundex, distance
The difficultly with extending native methods is that other libraries can do the same thing. There should be a mechanism that warns the user if an existing method is being overwritten and then freeze the object if in a strict mode setting?
Debugging such conflicts is incredibly difficult for developers so I consider this relatively import.
This can result in a large string rather than a large number.
Just a little bit of sugar to make them fit in with the rest of the native functions.
Yes Sir!
But ECMA5 browsers only. I'm thinking it will make a fantastic tool to Zepto.JS's belt.
'There are %d monkeys in the %s'.format(10, 'stream');
Time to think about using a more versatile testing framework.
With inspiration from Ruby:
ceil() / floor()
round(precision)
lcm(_int) / gcd(_int)
isOdd() / isEven()
times() / upto() / downto()
chr()
next() / prev()
I think so anyway. Maybe an Object.shuffle too?
Here's the Node REPL Output
> require('toolkit')
{ version: '1.4.0' }
> Array.intersect([[2,3,4], [3,4,5]])
TypeError: Object function Array() { [native code] } has no method 'intersect'
at [object Context]:1:7
at Interface.<anonymous> (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream.<anonymous> (readline.js:73:12)
at ReadStream.emit (events.js:81:20)
at ReadStream._emitKey (tty_posix.js:307:10)
at ReadStream.onData (tty_posix.js:70:12)
>
Both methods should first clone the object as to preserve any non-enumerable properties and methods.
Often one will have an array of arrays they want to find an intersection with (for instance). At the moment they would have to take the first item out of the array and apply the function to the rest of the elements like:
arr.splice(1).intersect.apply(arr);
Which is difficult to read and if you don't want to mess up the original array you spill into two lines:
var first = arr[0];
first.intersect.apply(arr.slice(1));
I'm not happy with this so I propose adding some helper methods. Something like:
Array.intersect(arr);
Although incredibly easy to implement:
Object.keys(obj).length
It seems wise to also have it as an extra method.
This should be just the value not [value]
This is somewhat urgent.
Array.intersect => Array#intersect (if arguments.length == 0)
Array.diff => Array#diff (if arguments.length == 0)
Array.union => Array#union (if arguments.length == 0)
In number.prototype
A boring job but it has to be done eventually!
Like map - except applies the user function to the object instance without cloning.
I love the idea but '!' is a reserved token in javascript so:
foo.bar!() is not possible. I suggest the use of the $ instead:
foo.bar$() to the operation on the instance object rather than returning a clone.
Fairly important as I start delving into the depths of the Date.
Due to Mozilla's inability to supply inline comments in functions when .toString() is called on them.
From underscore.js:
bind, bindAll, memoize, delay, defer, throttle, debounce, once, after, wrap, compose
From Ruby:
new, equal
From Me:
tap
Hi, I know this is a bold question, but figured it wouldn't hurt to try.
I have an idea for a library and toolkit
is the perfect name for it, and I was wondering if you would consider adding me as an owner to the toolkit
package on NPM.
Since NPM does not allow existing published versions of a package to be deleted or modified, anything that currently depends on toolkit
will not be effected at all by any changes.
Thanks in advance for considering my request!
If you do decide to add me, you simply need to enter the following in the command line:
$ npm owner add jonschlinkert toolkit
Thanks!
Must have been overlooked - this is fairly serious.
Using Object.create() simply uses the parent object as the clone's prototype which is exactly the opposite of a clone.
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.