{"library":"metal-aop","title":"Metal.js AOP Utility","description":"metal-aop is a utility package that provides Aspect-Oriented Programming (AOP) capabilities specifically for applications built with the Metal.js framework. AOP allows developers to modularize cross-cutting concerns such as logging, security, and transaction management, by defining advice (code to be executed) and applying it at specific join points (execution points) in the application's flow. The package's latest stable version is 3.0.0, released approximately eight years ago. However, the underlying Metal.js framework has been officially deprecated by Liferay, its primary maintainer, with no active staffing for open-source support and no future plans to use the framework. Consequently, metal-aop is effectively an abandoned project, meaning it receives no new features, bug fixes, or security patches. Its differentiators were primarily its tight integration with Metal.js's component model, which is no longer actively developed.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install metal-aop"],"cli":null},"imports":["const Aop = require('metal-aop');","const { Aspect } = require('metal-aop');","const { before } = require('metal-aop/src/aop'); // Example for a specific advice type"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const Aop = require('metal-aop');\n\nclass MyService {\n  doSomething(data) {\n    console.log(`Processing data: ${data}`);\n    return `Result for ${data}`;\n  }\n\n  anotherMethod() {\n    console.log('Another method called.');\n  }\n}\n\nconst myServiceInstance = new MyService();\n\n// Define a 'before' advice\nAop.before(myServiceInstance, 'doSomething', function(originalArgs) {\n  console.log(`[AOP-Before] Preparing to call doSomething with: ${originalArgs[0]}`);\n});\n\n// Define an 'after' advice\nAop.after(myServiceInstance, 'doSomething', function(originalArgs, result) {\n  console.log(`[AOP-After] doSomething finished. Original args: ${originalArgs[0]}, Result: ${result}`);\n});\n\n// Define an 'around' advice\nAop.around(myServiceInstance, 'anotherMethod', function(originalFn) {\n  console.log('[AOP-Around] Before calling anotherMethod');\n  const result = originalFn(); // Call the original method\n  console.log('[AOP-Around] After calling anotherMethod');\n  return result;\n});\n\nconsole.log('--- Calling doSomething ---');\nmyServiceInstance.doSomething('input123');\n\nconsole.log('\\n--- Calling anotherMethod ---');\nmyServiceInstance.anotherMethod();","lang":"javascript","description":"This quickstart demonstrates how to apply 'before', 'after', and 'around' advice to methods of a class using metal-aop, illustrating basic Aspect-Oriented Programming (AOP) concepts like interception.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}