2016-09-10 曹强
前言 在对Module模式有个熟悉的了解之后,我们来认识一个稍有改进的版本——ChristianHeilmann的Revealing Module模式。 模式的由来 原来的Module模式可能无法实现这样的需求: 当我们从另一个方法调用一个公有方法或者访问公有变量时,必须要重复主对象的名称。而且使用Module时必须要切换到对象字面量表示法来让某种方法变成公有方法。 我们需要的可能是这样的一个模式: 能够在私有范围内简单定义所有的函数和变量,并返回一个匿名对象,它拥有指向私有函数的指针,该函数是它希望展示为公有的方法。 有点拗口,还是上代码吧 (☆_☆) more 代码 ``` var myRevealingModu 继续阅读 »
2016-09-10 曹强
写在前面 Module模式最初被定义为一种在传统软件工程中为类提供私有和公有封装的方法。而在Javascript中,Module模式用于进一步模拟类的概念,通过这种方式,能够使一个单独的对象拥有公有/私有的方法和变量,从而屏蔽来自全局作用域的特殊部分。产生的结果是:函数名与在页面上其他脚本定义的函数冲突的可能性降低。 应当注意的一点是:在Javascript没有private访问修饰符因此算不得真正的私有,而是通过函数作用域来模拟私有这个概念。在Module模式内由于闭包的存在,声明的变量和方法只在该模式内部可用,但在返回对象上定义的变量和方法是可以对外访问的。 more 示例 var testModule=(functi 继续阅读 »
2015-03-16 Mithrilwoodrat
参考 The Linux Kernel Module Programming Guide , linux kernel hacking lessons 继续阅读 »
2016-03-22 Xiaosong Gao
Node.js中exports和module.exports有什么不同? 你肯定对Node.js模块中用来创建函数的exports对象很熟悉(假设一个名为rocker.js的文件): exports.name = function() { console.log('My name is Lemmy Kilmister'); }; 继续阅读 »
2015-11-29 Oliver Wang
没什么好解释的,直接看代码吧。 js (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. //define(['jquery', 'underscore'], factory); } else if (typeof exports === 'object') { // Node/CommonJS style for Browserify/Seajs module.exports = 继续阅读 »
2016-02-05 ruki
New features Add automaticlly check libc interfaces Support custom allocator Add trace for allocator in the debug mode Add static_pool module Add stream interfaces for reading all data to string Add adler32 hash algorithm Add tb_memmem interface Add regex module with pcre, pcre2 or posix regex Changes Optimize stre 继续阅读 »
2016-10-30 ruki
New features Support make command and compile directly without xmake Add switch context interfaces into platform module Add coroutine module (supports i386, x86_64, arm, arm64 ..) Add simple http server demo using coroutine Add simple spider using coroutine Add io poller interfaces(with epoll, poll, kqueue, select) Su 继续阅读 »
2016-08-29 ruki
New features Add wait multi-processes interface Add uuid generator Add hash library module Add __tb_deprecated__ keyword and option Changes Move some utils interfaces to the hash module Rewrite random generator Bugs fixed Fix stdout compatibility issue for vs2015 Fix process arguments length limit 继续阅读 »
2015-11-09 litaotao
1. import module 流程 首先,明确一下 import module_name 和 from module_name import module_element 是两条可执行的语句。 其次,sys.modules 里记录了当前 run time 下所有已经导出的 module。 继续阅读 »
2016-07-08 ruki
xmake v2.0 has supported the plugin module and we can develop ourself plugin module conveniently. We can run command xmake -h to look over some builtin plugins of xmake Plugins: l, lua Run the lua script. m, macro Run the given macro. 继续阅读 »