The project aims to develop a JavaScript module framework that is simple to use with some interesting features. 本計畫目標是建立一個簡單上手的 JavaScript 程式庫架構。
<script type="text/JavaScript" src="path/to/ce.js">
// { "run" : "module name or callback" }
</script>
// Insert from browser console
var cejs_node = document.createElement("script");
cejs_node.setAttribute('src', 'https://kanasimi.github.io/CeJS/ce.js');
cejs_node.setAttribute('type', 'text/javascript');
document.head.appendChild(cejs_node);
if (!window.CeL) window.CeL = { initializer : function() { CeL.run('interact.DOM', initialization); } };
function initialization() {}
// CeL.run( 'module.name', function callback() { /* ... */ } );
CeL.run([ 'data.math', 'application.debug.log' ], function() {
CeL.assert([ CeL.GCD(4, 6), 2 ]);
});
npm
安裝的可能不是最新版本,這裡示範的是最新版本的安裝方法。
不囉嗦,已經做過的步驟可以跳過:
下載 GitHub repository 安裝檔 GitHub.updater.node.js
在命令行界面下,進到 GitHub repository 安裝檔(GitHub.updater.node.js
)所在的目錄,執行命令以下載 CeJS 程式庫:
node GitHub.updater.node.js
CeJS 程式庫應該已經解壓縮,並且放在安裝檔所在目錄的 CeJS-master 目錄下,可以開始試用:
node
// or: require('./CeJS-master/_for include/node.loader.js');
require('./_CeL.loader.nodejs.js');
var cejs = require("cejs");
CeL.run([ 'data.math', 'application.debug.log' ]);
CeL.assert([ CeL.GCD(4, 6), 2 ]);
每次要更新到最新 CeJS 程式庫時,只要重新執行一次 GitHub repository 安裝檔即可。
$ npm install cejs
npm
安裝的可能不是最新版,尚未加入最新功能。建議下載最新版本壓縮檔,解開後配置;而不是直接執行 npm install
安裝舊版的程式庫。鑒於更新頻繁,有些功能可能最新版本才具備;若是執行的程式採用了新功能,將會發生嚴重錯誤。此時您可直接到 GitHub 下載最新版本壓縮檔,解開後配置。
Since the frequent updates of the code, some features may work at the latest version only; it's recommended download the latest version at GitHub, and then configure the library.
For using the alpha version of CeJS, you can set { "dependencies": {"cejs": "github:kanasimi/cejs"}}
in the package.json, or use a setup script:
Install node.js, wget/curl and 7-Zip. e.g.,
yum -y install nodejs wget p7zip
fetch CeJS updater script. e.g.,
cd /tmp
mkdir CeJS && cd CeJS
wget "https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js" || curl -O https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js
# This script will download + extract CeJS library at ./CeJS-master.
node GitHub.updater.node.js
See GitHub.updater.node.js for automatic updating configuration.
Copy the loader file, _CeL.loader.nodejs.js
to the target directory (e.g., the same as the script file).
Create the repository_path_list_file, _repository_path_list.txt
in the same directory.
Set the path list to search the library base: Write to the repository_path_list_file (_repository_path_list.txt
), one path per line.
to use in a script file:
//global.use_cejs_mudule = true;
require('./_CeL.loader.nodejs.js');
Let's try it:
$ node
// Load CeJS library.
require('cejs');
// Load modules.
// CeL.run( 'module.name', function callback() { /* ... */ } );
CeL.run([ 'data.math', 'application.debug.log' ]);
// Running codes.
CeL.assert(CeL.GCD(48, 64) === 16);
CeL.assert([ "2³⋅13⋅80611⋅82217",
CeL.factorize(689269837048).toString() ], 'factorize');
For further introduction, please see the wiki. 進一步介紹請參閱本計畫之 wiki。
Live demo: 紀年轉換工具.
直式四則運算 (elementary arithmetic),即直式加減乘除、長除法。
See compatibility.js and native.js.
CeL
。詳細請參閱概念介紹頁。
Contact us at GitHub.
(This document is written by GitHub Flavored Markdown.)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。