UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

19 lines (17 loc) 561 B
function get_resource_type(handle) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: get_resource_type('a'); // * returns 1: false var getFuncName = function(fn) { var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn); if (!name) { return '(Anonymous)'; } return name[1]; }; if (!handle || typeof handle !== 'object' || !handle.constructor || getFuncName(handle.constructor) !== 'PHPJS_Resource') { return false; } return handle.get_resource_type(); }