Comments (13)
There's still time. I'm feeling a bit sad, the object["property"] syntax can't
be used, though ;-)
Also: don't you think the Hash.merge should do a "deep" merge (now it's
overwriting members of the Hash type).
Original comment by [email protected]
on 27 Jul 2007 at 10:41
from base2.
> I'm feeling a bit sad, the object["property"]
Are you talking about base2 or es4?
> don't you think the Hash.merge should do a "deep" merge
What do you mean by "deep" merge?
Original comment by [email protected]
on 27 Jul 2007 at 11:01
from base2.
//--| Shallow merge
var x=new Hash( { p:"doeke", a: { b:1 } } );
x.merge( { a: { c:1 } } );
x.fetch("a").b === undefined;
x.fetch("a").c == 1;
the initial object of property a (b:1) is overwritten by the merge (c:1).
//--| Deep merge
var x=new Hash( { p:"doeke", a: { b:1 } } );
x.merge( { a: { c:1 } } );
x.fetch("a").b === undefined;
x.fetch("a").fetch("b") == 1;
x.fetch("a").c === undefined;
x.fetch("a").fetch("c") == 1;
So basically: inner Object objects are converted to Hash objects, and inner
objects are also merged.
BTW: Arrays probably also need to support "merge".
Original comment by [email protected]
on 28 Jul 2007 at 10:08
from base2.
I think we'll keep it as a shallow merge.
Any thoughts on the renaming?
Original comment by [email protected]
on 10 Aug 2007 at 4:19
from base2.
What are your thoughts one shallow merge? I accept your final vote, but if you
don't give even one argument, my
enthousiasm goes down...
My argument to support a deep merge is to support "options" (like in prototype)
with hierarchy. For example, I have
some options with http:
defaultOptions=new Dict({
method: "GET",
isAsync: true,
username: undefined,
password: undefined,
headers: new Dict({"X-Requested-By": "base2.HttpTransport"})
});
The only reason to not support a "deep merge" is code size. But we could also
make it optional:
merge: function(values, deepMerge)
But I'm also happy to stick to my own Dict-implementation...
Thoughts on renaming: I just like the name "Dict", but I prefer standards more.
I actually lost track of the
Hash/Dict/HashMap/... discussion. Are the es4 method names decided on?
Original comment by [email protected]
on 11 Aug 2007 at 12:48
from base2.
Do you want to raise a separate issue for deep merging? I can always add it
later.
The problem is that the merge() methods currently take multiple arguments.
There is
also union() to consider, which is similar to merge().
> Are the es4 method names decided on?
I lost track of that discussion too.
Original comment by [email protected]
on 11 Aug 2007 at 7:24
from base2.
> Do you want to raise a separate issue for deep merging? I can always add it
later.
> The problem is that the merge() methods currently take multiple arguments.
OK. We can always create a module with a deepMerge method or something. I think
about it a bit more, before I
raise an issue.
About naming: the new proposal seems stable (Brendan and Hansen seem resolute
on this topic now):
http://wiki.ecmascript.org/doku.php?id=proposals:dictionary
Method naming after java, the class is called "Map". I think we should rename
both methods and class-name.
What do you think of the constructor opts?
Original comment by [email protected]
on 11 Aug 2007 at 9:27
from base2.
The constructor ops alone make me think that this class should be separate from
Hash/Collection. base2's Hash class is very simple and basically just extends
JavaScript's Object class. I like the fact that the Hash constructor allows
this:
var hash = new Hash({
a: 1,
b: 2
});
I think that we should rename store/fetch etc. Map can possibly be subclass of
Hash
or Collection?
Original comment by [email protected]
on 12 Aug 2007 at 1:48
from base2.
Ha. Just noticed that Map has two constructors...
Original comment by [email protected]
on 12 Aug 2007 at 1:54
from base2.
I like the feature, the Map object allows to make the keys case insensitive
(via the equals method). But we can
do that via another mechanism. What do you think?
I like the current constructor-format.
> I think that we should rename store/fetch etc.
Yeah.
> Map can possibly be subclass of Hash or Collection?
version 2.0 ;-)
Original comment by [email protected]
on 12 Aug 2007 at 1:58
from base2.
I decided to go ahead with the renaming. This will be in the next update.
Original comment by [email protected]
on 30 Aug 2007 at 4:07
- Changed state: Started
from base2.
Original comment by [email protected]
on 30 Aug 2007 at 5:34
- Added labels: Type-Enhancement
- Removed labels: Type-Discuss
from base2.
Original comment by [email protected]
on 5 Dec 2007 at 4:48
- Changed state: Fixed
from base2.
Related Issues (20)
- Please add Array2.make HOT 2
- 'Unspecified error' when loading a page via iframe in IE8.
- Function.bind() defined in Firefox 4 conflicts with Base2's own bind()s. HOT 1
- base62 encoding shrinked script fails with 3.1 but works with 3.0 HOT 3
- Contact to the owner of the project? HOT 1
- DOMContentLoaded does not fire in Safari 3.0.4 (and possibly other versions) HOT 1
- IE throws "Unspecified Error" when calling some methods or accessing some properties of elements not attached to a document
- base2.jsb.eventDispatcher fails to dispatch (delegated?) events under IE9
- Listeners for (before)?(cut|copy|paste) events are not executed in IE7-9 HOT 1
- Patch for /trunk/src/apps/MiniWeb/Client.js
- Patch for /trunk/src/apps/MiniWeb/Client.js
- document not geting extended.
- getting opacity in getComputedPropertyValue of ViewCSS returns empty string on element without opacity set
- Eclipse "Syntax error on token "new", ArrayLiteralHeader expected after this token", l. 19 of v1.0.2 of base2.js HOT 3
- Consider relying on HTML ClassList API
- :checked pseudo-class doesn't match selected option elements.
- Non ascii strings broken when encoded HOT 1
- classList.remove can incorrectly trigger IE's onpropertychange event.
- Allow Base cast specialization HOT 1
- Patch for /trunk/src/apps/packer/Base62.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base2.