forked from FINAKON/HelpProject
1. Initial Commit - a boiler plate code and POC to realize the concept of context sensitive help 2. Frontend code written in ReactJS 3. Backend code written in Java, Spring Boot Framework 4. Frontend Start: pre-requisites : node, npm npm run dev ==> to start the frontend vite server 5. Backend Start: pre-requisites : java, mvn mvn spring-boot:run ==> to start the backend server 6. Visit http://localhost:5173/ for basic demo of help, press F1 in textboxes 7. Visit http://localhost:5173/editor and enter "admin123" to add/modify texts. Happy Coding !!! Thank you, Bhargava.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
var GetIntrinsic = require('get-intrinsic');
|
|
var define = require('define-data-property');
|
|
var hasDescriptors = require('has-property-descriptors')();
|
|
var gOPD = require('gopd');
|
|
|
|
var $TypeError = require('es-errors/type');
|
|
var $floor = GetIntrinsic('%Math.floor%');
|
|
|
|
/** @type {import('.')} */
|
|
module.exports = function setFunctionLength(fn, length) {
|
|
if (typeof fn !== 'function') {
|
|
throw new $TypeError('`fn` is not a function');
|
|
}
|
|
if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {
|
|
throw new $TypeError('`length` must be a positive 32-bit integer');
|
|
}
|
|
|
|
var loose = arguments.length > 2 && !!arguments[2];
|
|
|
|
var functionLengthIsConfigurable = true;
|
|
var functionLengthIsWritable = true;
|
|
if ('length' in fn && gOPD) {
|
|
var desc = gOPD(fn, 'length');
|
|
if (desc && !desc.configurable) {
|
|
functionLengthIsConfigurable = false;
|
|
}
|
|
if (desc && !desc.writable) {
|
|
functionLengthIsWritable = false;
|
|
}
|
|
}
|
|
|
|
if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
|
|
if (hasDescriptors) {
|
|
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length, true, true);
|
|
} else {
|
|
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length);
|
|
}
|
|
}
|
|
return fn;
|
|
};
|