[Javascript] unsubscribe
Christie Mason
cmason at managersforum.com
Sun Jan 4 03:35:39 CST 2015
----------------------------------------
From: "Troy III Ajnej" <trojani2000 at hotmail.com>
Sent: Sunday, January 04, 2015 3:07 AM
To: "javascript at lists.evolt.org" <javascript at lists.evolt.org>
Subject: [Javascript] revisiting exists() method
> ---------------------------8<---------------------------
> exists=
> /*b.b. Troy III p.a.e.*/
> function(x){try{return!!(0,eval)(x)}catch(e){return!1}}
> --------------------------->8--------------------------- You probably
remember this (above) function, the following was written soon after,
but...Well, - time to share... [code]
function isNS(arg,f) { /*b.b. Troy III p.a.e.*/ var i, a = arg.split("."),
c = this, s = [], b, r; f = f || 0; for( i in a ) { c ? a[i] in c ? ( c =
c[ a[i] ], s.push( a[i] ), b = !0 ) : b = !1 : 0; } r = [ b, c, s, a, arg
]; return f < 0 ? r : r[+f||f] }
[/code]
[example]isNS("myObject.property.subProperty.myMethod");
_> Boolean : true/false // applying f argument functionality modifier:
isNS("myObject.property.subProperty.myMethod", [ f ] ); where f can be: -1;
0|false|undefined; 1|true; 2; 3 or 4.Description:-1 _> returns array object
containing complete inoculation.0 _> optional; returns Boolean: true (if
complete NS chain exist) : false (if it's broken).1 _> if NS* query exists,
case true: returns the existing value, if not, case false: returns the last
valid context if any, or the global object if root doesn't exist.2 _>
returns an array of existing namespaces in the argument query.3 _> returns
an array containing all specified namespaces.4 _> returns the original
query string.
This simple function allows the introduction of a secure and quite
elaborate Guesswork in JavaScript.
Possible use case:
...
var qNSret = isNS( [string], -1) ;if( qNSret[0] ){ send( qNSret[1] ) else
notify( qNSret[4], qNSret[2] ) };...
* already familiar "NS" initials stand for "Namespace".
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Troy III
progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript
More information about the Javascript
mailing list