{"id":18784817,"url":"https://github.com/zy445566/node-c-jit","last_synced_at":"2025-04-13T12:33:25.785Z","repository":{"id":57192202,"uuid":"112133717","full_name":"zy445566/node-c-jit","owner":"zy445566","description":"node.JS run C language Just In Time","archived":false,"fork":false,"pushed_at":"2018-11-23T02:05:28.000Z","size":17,"stargazers_count":26,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T03:41:35.466Z","etag":null,"topics":["c","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/zy445566.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":"2017-11-27T01:48:15.000Z","updated_at":"2023-09-08T17:33:11.000Z","dependencies_parsed_at":"2022-09-01T06:02:44.213Z","dependency_job_id":null,"html_url":"https://github.com/zy445566/node-c-jit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zy445566%2Fnode-c-jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zy445566%2Fnode-c-jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zy445566%2Fnode-c-jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zy445566%2Fnode-c-jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zy445566","download_url":"https://codeload.github.com/zy445566/node-c-jit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248614767,"owners_count":21133780,"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":["c","nodejs"],"created_at":"2024-11-07T20:44:07.529Z","updated_at":"2025-04-13T12:33:25.534Z","avatar_url":"https://github.com/zy445566.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-c-jit\n[![Build Status](https://travis-ci.org/zy445566/node-c-jit.svg?branch=master)](https://travis-ci.org/zy445566/node-c-jit) \n\u003cbr /\u003e\nnode.JS run C language Just In Time\n\n\n\n# install\n-------------------\n```sh\nnpm install c-jit\n```\n\n# prepare\n-------------------\n```\nnpm install node-gyp -g\n```\nYou can see:https://github.com/nodejs/node-gyp#installation\n\n# example\n-------------------\nGrammar reference(NAN example):https://github.com/nodejs/node-addon-examples \u003cbr /\u003e\n\nsync:\n```node\nconst CJit = require(\"c-jit\");\nconst path = require(\"path\");\nlet cJit  = new CJit();\n\n// run by c code sync\nlet funcByrunSync = cJit.runSync(`\n  if (info.Length() \u003c 2) {\n    Nan::ThrowTypeError(\"Wrong number of arguments\");\n    return;\n  }\n\n  if (!info[0]-\u003eIsNumber() || !info[1]-\u003eIsNumber()) {\n    Nan::ThrowTypeError(\"Wrong arguments\");\n    return;\n  }\n\n  double arg0 = info[0]-\u003eNumberValue();\n  double arg1 = info[1]-\u003eNumberValue();\n  v8::Local\u003cv8::Number\u003e num = Nan::New(arg0 + arg1);\n\n  info.GetReturnValue().Set(num);\n`);\nconsole.log(\"This should be eight(by run sync):\"+funcByrunSync(3,5));\n\n//run by file sync\nlet funcByfileSync = cJit.runByFileSync(path.join(__dirname,'test.cc'));\nconsole.log(\"This should be twelve(by file sync):\"+funcByfileSync(6,6));\n\n```\n\nasync:\n```node\nconst CJit = require(\"c-jit\");\nconst path = require(\"path\");\nlet cJit  = new CJit();\n\nlet funcByrun = cJit.run(`\n  if (info.Length() \u003c 2) { \n    Nan::ThrowTypeError(\"Wrong number of arguments\"); \n    return; \n  } \n \n  if (!info[0]-\u003eIsNumber() || !info[1]-\u003eIsNumber()) { \n    Nan::ThrowTypeError(\"Wrong arguments\"); \n    return; \n  } \n \n  double arg0 = info[0]-\u003eNumberValue(); \n  double arg1 = info[1]-\u003eNumberValue(); \n  v8::Local\u003cv8::Number\u003e num = Nan::New(arg0 + arg1); \n \n  info.GetReturnValue().Set(num); \n`,(err,func)=\u003e{\n  if (err){console.log(err);return;}\n  console.log(\"This should be eight(by run):\"+func(3,5));\n});\n\n\n// run by file\nlet funcByfile = cJit.runByFile(path.join(__dirname,'test.cc'),(err,func)=\u003e{\n  if (err){console.log(err);return;}\n  console.log(\"This should be twelve(by file):\"+func(6,6));\n});\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzy445566%2Fnode-c-jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzy445566%2Fnode-c-jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzy445566%2Fnode-c-jit/lists"}