fing

Meta tools for Node/Javascript

fing

Meta tools for Node/Javascript

 
coffee> require 'fing'
 
 
 
coffee> class Thing
[Function: Thing]
coffee> 
coffee> 
coffee> Thing.fing
{ type: 'prototype',    # <------------------ is a 'class' or function 
  name: 'Thing',
  args: [],             # <------------------ constructor / function signature 
  id: 1,                
  ref: 'prototype:Thing:1' }
 
 
 
coffee> thing1 = new Thing
{}
coffee> 
coffee> thing1.fing
{ type: 'instance',    # <------------------- an instance of a 'class' 
  name: 'Thing',
  args: [],            # <------------------- constructor signature 
  id: 2,               # <------------------- unique  
  ref: 'instance:Thing:2' }
 
 
 
coffee> thing2 = new Thing
{}
coffee> thing2.fing
{ type: 'instance',
  name: 'Thing',
  args: [],
  id: 3,                
  ref: 'instance:Thing:3' }  # <------------ unique reference 
 
 
 
coffee> Thing.fing
{ type: 'prototype',
  name: 'Thing',
  args: [],
  id: 1,                # <--------------- Thing still has id 1 
  ref: 'prototype:Thing:1' }
 
 
 
coffee> fn = (arg1,arg2) ->
[Function]
coffee> fn.fing
{ type: 'prototype',
  name: '',                                      # <---- anonymous function 
  args: [ { name: 'arg1' }{ name: 'arg2' } ],  # <---- function arg signature 
  id: 5,                                         # <---- unique id 
  ref: 'prototype::5' }                          
 
 
 
coffee> test = -> fing.trace()
[Function]
coffee> test()
[ { call: 'test',
    file: 'evalmachine.<anonymous>',
    line: 4,
    col: 15 } ]
coffee> 
 
 

The generated identity is only ensured unique for single threaded environments, eg. Nodejs

  • Protected prototype override from multiple requires
  • Added fing.trace()
  • Added ano_ther underscode to __id
  • Hid ___id away, as a non enumerating property
  • Added <object|function/prototype>.fing.[type,name,args,id,ref]
  • Added .fing.args (= [{name:'arg1name'},{name:'arg2name'},...])