UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

22 lines (20 loc) 753 B
function rewind(handle) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: var h = fopen('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm', 'r'); // * example 1: fread(h, 100); // * example 1: rewind(h); // * returns 1: true var getFuncName = function(fn) { var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn); if (!name) { return '(Anonymous)'; } return name[1]; }; if (!this.php_js || !this.php_js.resourceData || !this.php_js.resourceDataPointer || !handle || !handle.constructor || getFuncName(handle.constructor) !== 'PHPJS_Resource') { return false; } this.php_js.resourceDataPointer[handle.id] = 0; return true; }