{"id":25349824,"url":"https://github.com/yankeguo-deprecated/scriptlet","last_synced_at":"2026-05-07T15:40:15.456Z","repository":{"id":47994145,"uuid":"195207068","full_name":"yankeguo-deprecated/scriptlet","owner":"yankeguo-deprecated","description":"scriptlet engine for node.js","archived":false,"fork":false,"pushed_at":"2022-12-30T18:15:24.000Z","size":86,"stargazers_count":0,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-12T23:13:44.602Z","etag":null,"topics":["javascript","nodejs","scriptlets","serverless"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yankeguo-deprecated.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-04T09:03:47.000Z","updated_at":"2022-09-02T09:16:18.000Z","dependencies_parsed_at":"2023-01-31T12:46:00.709Z","dependency_job_id":null,"html_url":"https://github.com/yankeguo-deprecated/scriptlet","commit_stats":null,"previous_names":["guoyk93/scriptlet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo-deprecated%2Fscriptlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo-deprecated%2Fscriptlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo-deprecated%2Fscriptlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yankeguo-deprecated%2Fscriptlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yankeguo-deprecated","download_url":"https://codeload.github.com/yankeguo-deprecated/scriptlet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247933970,"owners_count":21020710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","scriptlets","serverless"],"created_at":"2025-02-14T16:58:20.628Z","updated_at":"2025-10-07T13:54:23.942Z","avatar_url":"https://github.com/yankeguo-deprecated.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scriptlet\n\n[![Build Status](https://travis-ci.org/guoyk93/scriptlet.svg?branch=master)](https://travis-ci.org/guoyk93/scriptlet)\n![GitHub](https://img.shields.io/github/license/guoyk93/scriptlet.svg)\n\nscriptlet engine for node.js\n\n## What is a Scriptlet?\n\nA **scriptlet** is a piece of JavaScript code that could finish running in finite time.\n\nThese kinds of code can be regarded as **scriptlet**\n\n* definition of a object / function / scalar constants\n* copy a file to another folder\n* connect to redis server and set a value\n* fetch a web page and save it to a database\n\nThese kinds of code can NOT be regarded as **scriptlet**\n\n* a web server\n* a job server\n\n## How to define and run a **scriptlet**\n\nUnlike standard Node.js module, **scriptlet** are defined in `AMD` style.\n\nYou can easly run a **scriptlet** via this package.\n\n```javascript\n// helper.js\n//\n// this defines a static object\n\ndefine({\n    log(message) {\n        console.log(message)\n    }\n})\n\n// rm.js\n//\n// this defines a async function, will be evaluated while running\n\n// 'fs-extra' is a standard node.js module\n// './helper' is a relative scriptlet file defined above\n// '$in' is a injected value upon running, see 'index.js'\ndefine('fs-extra', '../helper', '$in', async function(fs, helper, $in) {\n    helper.log(`unlinking file ${$in}`)\n    await fs.unlink($in)\n})\n\n// index.js\n//\n// this runs the scriptlet rm.js with $in injected\nconst scriptlet = require('scriptlet')\nconst path = require('path')\nasync function main() {\n    await scriptlet.run(path.join(__dirname, 'rm.js'), {\n        // inject the '$in' arguments\n        extra: new Map(['$in', process.argv[2]]),\n        // use mtime based cache policy\n        cache: 'mtime'\n    })\n}\nmain()\n```\n\n## More\n\nYou can build a **scriptlet** based web server with hot-reload support or even build your own Amazon Lambda Service.\n\n## Credits\n\nGuo Y.K., MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo-deprecated%2Fscriptlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyankeguo-deprecated%2Fscriptlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyankeguo-deprecated%2Fscriptlet/lists"}