Message from discussion
Consider MooTools (was: Re: process.mixin)
Received: by 10.223.62.80 with SMTP id w16mr232496fah.22.1270297256824;
Sat, 03 Apr 2010 05:20:56 -0700 (PDT)
Received: by 10.223.62.80 with SMTP id w16mr232494fah.22.1270297256631;
Sat, 03 Apr 2010 05:20:56 -0700 (PDT)
Return-Path: <dracoblu...@googlemail.com>
Received: from mail-fx0-f218.google.com (mail-fx0-f218.google.com [209.85.220.218])
by gmr-mx.google.com with ESMTP id 17si775881fxm.11.2010.04.03.05.20.55;
Sat, 03 Apr 2010 05:20:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of dracoblu...@googlemail.com designates 209.85.220.218 as permitted sender) client-ip=209.85.220.218;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dracoblu...@googlemail.com designates 209.85.220.218 as permitted sender) smtp.mail=dracoblu...@googlemail.com; dkim=pass (test mode) header...@googlemail.com
Received: by mail-fx0-f218.google.com with SMTP id 10so1529603fxm.27
for <nodejs@googlegroups.com>; Sat, 03 Apr 2010 05:20:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=gamma;
h=domainkey-signature:mime-version:sender:received:in-reply-to
:references:date:x-google-sender-auth:received:message-id:subject
:from:to:content-type:content-transfer-encoding;
bh=XdaRGtDvz753VMGRUY/tXbzt1PBTo8LHtfzFzF/+XUk=;
b=OTkqjaOpctYP/iqqXpIfAIt2CfPYqygXyKc++23D5Ofu3trwmtyVyvRtAB+xLN8GZl
Ce9jJcBA3F/2WIWPFVcpEJApIiLk7oqHFiEGOZn+a66w96UP4ak75ps9IS5LclCx5ciL
BbhXUgFyUpv+fhAzz0+MpzwNdeaK7nI3eZycw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=googlemail.com; s=gamma;
h=mime-version:sender:in-reply-to:references:date
:x-google-sender-auth:message-id:subject:from:to:content-type
:content-transfer-encoding;
b=AofjN4a2mcfQoiuZbf969Trk+E59NTGZUYXO7CJfyv3oqh8QIdMPJH1y/f1OJbYNcK
srIA9kIDRdK+/lO2i2w9hSHC2tRFWRtKThVIUURwmwUTZbjwffuEn7ZQVuqV2qPqa6Xx
FA+AevxRDA5wcB8N5Wy9bJfXElybR24MPKa5s=
MIME-Version: 1.0
Sender: dracoblu...@googlemail.com
Received: by 10.239.157.141 with HTTP; Sat, 3 Apr 2010 05:20:55 -0700 (PDT)
In-Reply-To: <2e810015-9def-4f10-8401-d1d12aa0a...@q23g2000yqd.googlegroups.com>
References: <aaedcef51003081516wd5a2ccdn54e4c12ee4365...@mail.gmail.com>
<4B9E44FD.9060...@bloggen.dk>
<6ea556b21003161606k53e869f3hcbfd9a5d54df0...@mail.gmail.com>
<b0ab5fe6-310e-4f5a-9b51-894317609...@z11g2000yqz.googlegroups.com>
<2e810015-9def-4f10-8401-d1d12aa0a...@q23g2000yqd.googlegroups.com>
Date: Sat, 3 Apr 2010 14:20:55 +0200
Received: by 10.239.180.136 with SMTP id i8mr287349hbg.35.1270297255345; Sat,
03 Apr 2010 05:20:55 -0700 (PDT)
Message-ID: <v2s6de454e91004030520vfdc419edj36e91f89db065...@mail.gmail.com>
Subject: Re: [nodejs] Re: Consider MooTools (was: Re: process.mixin)
From: =?UTF-8?B?SmFuIFNjaMO8dHpl?= <J...@DracoBlue.de>
To: nodejs@googlegroups.com
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Thanks for the detailed list ;).
I was watching this and another thread to see what's best as
replacement for my usecase: A prototype (BaseApplication) should be
extended with Logging functionality.
extend(true, BaseApplication.prototype, Logging.prototype,
AnotherAspect.prototype);
The extend method can be found here:
http://github.com/DracoBlue/spludo/blob/master/core/util.js#L79 , it's
basicly jQuery's extend method, without other dependencies (no
isArray, isPlainObject and so on necessary).
Regards,
Draco
On Sat, Apr 3, 2010 at 11:42 AM, Marco Rogers <marco.rog...@gmail.com> wrot=
e:
> I finally got around to taking a look at both of the mixin
> replacements suggested by Kris and Rasmus
>
> http://github.com/rsms/oui/blob/master/oui/std-additions.js#L9
> http://github.com/280north/narwhal/blob/master/lib/util.js
>
> Found some things that might be considered issues with both.
>
> Kris, deepUpdate works great except it doesn't check for Getters and
> Setters. =C2=A0Instead it just ends up taking the value returned from any
> Getter properties that are copied. =C2=A0And if the property has only a
> Setter, the property name is created with a value of undefined.
> Examples:
>
> var o =3D {};
> util.object.deepUpdate(o, {get foo() { return 'foo'; }});
> // o =3D> { foo: 'foo' }
>
> var o =3D {};
> util.object.deepUpdate(o, {set foo(v) { sys.puts('My new value is ' +
> v); }});
> // o =3D> { foo: undefined }
>
> The version in Rasmus's oui lib handles Getters and Setters, but
> there's a small issue. =C2=A0The function only checks the Setter if the
> Getter is also present.
>
> var o =3D {};
> mixin(o, {get foo() { return 'foo'; }});
> // o =3D> { foo: [Getter] }
>
> var o =3D {};
> mixin(o, {get foo() { return 'bar'; }, set foo(v) { sys.puts('My new
> value is ' + v); }});
> { foo: [Getter/Setter] }
>
> var o =3D {};
> mixin(o, {set foo(v) { sys.puts('My new value is ' + v); }});
> // o =3D> { foo: undefined }
>
> It's completely valid to have a write only property, so it should
> probably copy both either way.
>
> Now I say these MIGHT be issues because the validity of each approach
> can be debated. =C2=A0copying getters/setters is certainly convenient on
> it's face. =C2=A0But it could lead to issues. =C2=A0The getter could be h=
ooked
> into changing some complex internal state of the mixin object. That
> also happens with regular functions though, so maybe that's moot. =C2=A0B=
ut
> what about closures? =C2=A0It's probably okay to copy over a function tha=
t
> references closure scope variables. =C2=A0But does that make sense for a
> getter? =C2=A0Do getters even pick up closures? I assume so, but it's aft=
er
> 5:30am and I don't have the brain power to check :). =C2=A0Anyway, I'm
> curious to hear people's thoughts on this.
>
> One more small difference is that Rasmus's function has a small check
> to prevent circular references (or at least that's how I'm reading
> it).
>
> ...
> else if (target !=3D=3D d.value) {
> =C2=A0 =C2=A0target[k] =3D d.value
> }
>
> If the value of the mixin property is actually a reference to the
> target object, don't do the mixin. =C2=A0Am I reading that right? =C2=A0F=
eels
> like a good idea although I don't know how often that would come up.
>
> Thanks for these functions guys. =C2=A0And the rest of the libraries as
> well. =C2=A0They're both really useful, and they dropped into the
> environment and worked no problem. =C2=A0However, Rasmus, I couldn't use
> the npm package manager with yours because you don't provide a
> package.json. =C2=A0Maybe on purpose because you don't expect that stuff =
to
> be pulled out of oui. =C2=A0Just a heads up though.
>
> :Marco
>
>
> On Mar 16, 8:26=C2=A0pm, Anders Hellerup Madsen
> <anders.hellerup.mad...@gmail.com> wrote:
>> I use MooTools. The download builder athttp://mootools.net/corecan
>> be used to only pick the parts of the framework that doesn't mess with
>> the DOM, and I think that it's a very cool base library to work from.
>> If you just want aprocess.mixin() replacement, check Core, and
>> uncheck everything else. The functions $mixin() function does whatproces=
s.mixin() used to.
>>
>> String, Array, Number, Function and Hash can also safely be added.
>> They mix in a lot of really nice convenience methods to the prototypes
>> of the basic objects.
>>
>> If you wanted to, could also add Class and Class.Extras from the core-
>> builder, or snatch Date, Date.Extras and the Date.<language> packages
>> for some much needed proper JavaScript date/time support.
>>
>> I'm not sure it would be a good idea to use this in library code, but
>> for applications this is a really neat package.
>>
>> On Mar 17, 12:06=C2=A0am, Rasmus Andersson <ras...@notion.se> wrote:
>>
>>
>>
>> > I'm using this simple version which covers all my needs:http://github.=
com/rsms/oui/blob/master/oui/std-additions.js#L9
>>
>> > On Mon, Mar 15, 2010 at 15:32, Jannick Knudsen <jann...@bloggen.dk> wr=
ote:
>> > > Dear nodejs'ers,
>>
>> > > Has anyone made a solid drop-in replacement forprocess.mixin?
>>
>> > > Or is everybody just doing their own hacks?
>>
>> > > /JJ
>>
>> > > --
>> > > You received this message because you are subscribed to the Google G=
roups
>> > > "nodejs" group.
>> > > To post to this group, send email to nodejs@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > nodejs+unsubscribe@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/nodejs?hl=3Den.
>>
>> > --
>> > Rasmus Andersson
>
> --
> You received this message because you are subscribed to the Google Groups=
"nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+unsubscribe@googlegr=
oups.com.
> For more options, visit this group at http://groups.google.com/group/node=
js?hl=3Den.
>
>
--=20
http://dracoblue.net