Babel plugin that compiles ES2015 unicode string and number literals to ES5
86
A utility library for working with Unix-style file permissions that need to support legacy JavaScript environments.
Build a permission manager that defines common file permission constants and provides a function to validate permission values. The library must work in older JavaScript environments (ES5) that don't support modern numeric literal syntax.
Write your source code using modern JavaScript syntax for better readability. Your permission constants should use octal notation with the 0o prefix (e.g., 0o755, 0O644) to clearly represent Unix file permissions.
The code must be transpiled to work in ES5 environments. Configure a build system using Babel to transform your modern code into ES5-compatible output. The transpiled code should be generated in a dist/ directory.
Define the following permission constants using octal notation:
PERMISSION_READ_ALL: Full read permissions (0o444)PERMISSION_WRITE_OWNER: Owner write permission (0o200)PERMISSION_EXECUTE_ALL: Full execute permissions (0o111)PERMISSION_STANDARD: Standard file permissions (0o644)PERMISSION_RESTRICTED: Restricted permissions (0o600)Implement a validatePermission(value) function that:
true if the permission value is between 0 and 511 (inclusive)false otherwiseSet up Babel configuration to transpile your source code for ES5 compatibility. The build output should work in environments that don't support modern numeric literals.
PERMISSION_READ_ALL constant equals 292 in the transpiled output @testPERMISSION_STANDARD constant equals 420 in the transpiled output @testvalidatePermission function returns true for value 493 @testvalidatePermission function returns false for value 512 @test@generates
/**
* Validates whether a permission value is within the valid range.
*
* @param {number} value - The permission value to validate
* @returns {boolean} True if valid (0-511), false otherwise
*/
function validatePermission(value) {
// Implementation here
}
// Permission constants
const PERMISSION_READ_ALL = 0o444;
const PERMISSION_WRITE_OWNER = 0o200;
const PERMISSION_EXECUTE_ALL = 0o111;
const PERMISSION_STANDARD = 0o644;
const PERMISSION_RESTRICTED = 0o600;
module.exports = {
validatePermission,
PERMISSION_READ_ALL,
PERMISSION_WRITE_OWNER,
PERMISSION_EXECUTE_ALL,
PERMISSION_STANDARD,
PERMISSION_RESTRICTED
};Provides transformation support for modern numeric literal syntax to ES5-compatible code.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-es2015-literalsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10