Created
May 1, 2020 13:15
-
-
Save jjff/3ac95e0043c179a69859950244dc39c1 to your computer and use it in GitHub Desktop.
t1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@glimmer/component'; | |
export default class extends Component { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@glimmer/component'; | |
export default class extends Component { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@glimmer/component'; | |
import EmberObject, { computed } from '@ember/object'; | |
//import { computed } from '@ember/object'; | |
export default class extends Component { | |
todos=null; | |
constructor() { | |
super(...arguments); | |
this.todos=[ | |
// init() { | |
// this.set('todos', [ | |
EmberObject.create({ isDone: true }), | |
EmberObject.create({ isDone: false }), | |
EmberObject.create({ isDone: true }), | |
] | |
// ]); | |
} | |
incomplete=computed('[email protected]', function() { | |
return this.todos.filterBy('isDone', false); | |
}) | |
h1=Object.prototype.toString.call(this.incomplete); | |
/** | |
* Return array paraments of a function | |
* @param {[function]} func function | |
* @return {[array]} parameters the functions | |
* | |
*/ | |
/* const */ | |
// https://stackoverflow.com/questions/8639010/how-to-get-all-properties-of-an-object | |
getFunctionParameters = (func) => { | |
if (typeof func !== 'function') { | |
throw new Error('A argument is not function.'); | |
} | |
const args = func.toString().match(/\((.*)\)/)[1]; | |
return args.split(',').map((arg) => { | |
if (arg.indexOf('=') === -1) return arg.trim(); | |
return arg | |
.split('=') | |
.map(val => val.trim()) | |
.join(' = '); | |
}); | |
}; | |
h2=this.getFunctionParameters(this.incomplete); | |
f4=()=>{return 'hallo';} | |
h4=this.f4(); | |
/** | |
* Return array paraments of a function | |
* @param {[function]} func function | |
* @return {[array]} parammeters the functions | |
* | |
const | |
*/ | |
getFunctionParameters = (func) => { | |
if (typeof func !== 'function') { | |
throw new Error('A argument is not function.'); | |
} | |
const args = func.toString().match(/\((.*)\)/)[1]; | |
return args.split(',').map((arg) => { | |
if (arg.indexOf('=') === -1) return arg.trim(); | |
return arg | |
.split('=') | |
.map(val => val.trim()) | |
.join(' = '); | |
}); | |
}; | |
/** | |
* Display details about an object at run-time | |
* @param {[any]} target Any object | |
* @return Nothing, all information will be display | |
*/ | |
// | |
// local test, is OK function b() { function c(){return 6}; return c()} | |
// | |
introspect = (target) => { | |
let m=[]; | |
this.l=(msg)=>{/*console.log(msg);*/ m.push(msg); return msg;} | |
this.t=(msg)=>{this.l('');this.l(msg);this.l('----------------');} | |
// get type of a target | |
const typeTarget = typeof target; | |
// variable for type attribute of the target | |
let typeAttr; | |
// for properties and methods of the target | |
let properties = []; | |
let methods = []; | |
// if target is array, keep names all enumerable properties, simple put - numbers of indexes | |
// otherwise set to null | |
const enumerableProperties = Array.isArray(target) ? Object.keys(target) : null; | |
// determination functions and properties of the target by a parent object | |
Object.getOwnPropertyNames(Object.getPrototypeOf(target)).forEach((name) => { | |
if (typeof target[name] === 'function') { | |
methods.push(name); | |
} else if (target.hasOwnProperty(name) && properties.indexOf(name) === -1) { | |
properties.push(name); | |
} | |
}); | |
// determination other functions and properties of the target | |
// filter it, if a name already added or if it is an array - filter all values of the indexes | |
Object.getOwnPropertyNames(target).forEach((name) => { | |
if (enumerableProperties !== null && enumerableProperties.indexOf(name) !== -1) { | |
return; | |
} | |
if (typeof target[name] === 'function') { | |
methods.push(name); | |
} else if (target.hasOwnProperty(name) && properties.indexOf(name) === -1) { | |
properties.push(name); | |
} | |
}); | |
// order properties and methods by name in reverse | |
properties = properties.reverse(); | |
methods = methods.reverse(); | |
// display an obtained information by groups | |
this.t('Definition: '); | |
this.l(`${typeTarget}: "${target}"`); | |
this.t(`Properties: ${properties.length}`); | |
for (let i = properties.length - 1; i >= 0; i -= 1) { | |
typeAttr = typeof target[properties[i]]; | |
this.l(`\t\t${properties[i]} --> ${typeAttr}`); | |
} | |
this.l(`Methods: ${methods.length}`); | |
for (let i = methods.length - 1; i >= 0; i -= 1) { | |
let args = | |
// functools. | |
this.getFunctionParameters(target[methods[i]]); | |
args = args.join(', '); | |
this.l(`\t\t${methods[i]} (${args})`); | |
} | |
return {properties,methods,m}; | |
}; | |
h3=this.introspect(this.incomplete); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.0", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.17.0", | |
"ember-template-compiler": "3.17.0", | |
"ember-testing": "3.17.0" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment