AMD规范
- 格式:doc
- 大小:42.00 KB
- 文档页数:4
amd规范下的define的参数以及⽤法CLONE⽽来1. AMD的由来 前端技术虽然在不断发展之中,却⼀直没有质的飞跃。
除了已有的各⼤著名框架,⽐如Dojo,JQuery,ExtJs等等,很多公司也都有着⾃⼰的前端开发框架。
这些框架的使⽤效率以及开发质量在很⼤程度上都取决于开发者对其的熟悉程度,以及对JavaScript的熟悉程度,这也是为什么很多公司的技术带头⼈都喜欢开发⼀个⾃⼰的框架。
开发⼀个⾃⼰会⽤的框架并不难,但开发⼀个⼤家都喜欢的框架却很难。
从⼀个框架迁移到⼀个新的框架,开发者很有可能还会按照原有框架的思维去思考和解决问题。
这其中的⼀个重要原因就是JavaScript本⾝的灵活性:框架没办法绝对的约束你的⾏为,⼀件事情总可以⽤多种途径去实现,所以我们只能在⽅法学上去引导正确的实施⽅法。
庆幸的是,在这个层⾯上的软件⽅法学研究,⼀直有⼈在去不断的尝试和改进,CommonJS就是其中的⼀个重要组织。
他们提出了许多新的JavaScript架构⽅案和标准,希望能为前端开发提供银弹,提供统⼀的指引。
AMD规范就是其中⽐较著名⼀个,全称是Asynchronous Module Definition,即异步模块加载机制。
从它的规范描述页⾯看,AMD很短也很简单,但它却完整描述了模块的定义,依赖关系,引⽤关系以及加载机制。
从它被requireJS,NodeJs,Dojo,JQuery使⽤也可以看出它具有很⼤的价值,没错,JQuery近期也采⽤了AMD规范。
在这篇⽂章中,我们就将介绍AMD的性质,⽤法,优势以及应⽤场景。
从AMD 中我们也能学习到如何在更⾼层⾯去设计⾃⼰的前端应⽤。
2. AMD是什么 作为⼀个规范,只需定义其语法API,⽽不关⼼其实现。
AMD规范简单到只有⼀个API,即define函数: define([module-name?], [array-of-dependencies?], [module-factory-or-object]); 其中: module-name: 模块标识,可以省略。
前端⾯试题整理—Node篇1、node有哪些特征,与其他服务器端对⽐ 特征:单线程、事件驱动、⾮阻塞I/O node ⽆法直接渲染静态页⾯,提供静态服务 node 没有根⽬录的概念 node 必须通过路由程序指定⽂件才能渲染⽂件 node ⽐其他服务端性能更好,速度更快2、CommonJS中require/exports和ES6中import/export区别 CommonJS模块的重要特性是加载时执⾏,及脚本代码在require的时候,就会全部执⾏。
⼀旦出现某个模块被“循环加载”就只输出已经执⾏的部分,还没有执⾏的部分是不输出的 ES6模块是动态引⽤,如果使⽤import从⼀个模块加载变量,那些变量不会缓存,⽽是成为⼀个指向被加载模块的引⽤,impor/export最终都是编译为require/exports来执⾏的4、使⽤npm有哪些好处? 通过NPM,你可以安装和管理项⽬的依赖,并且能够指明依赖项的具体版本号,可以通过package.json⽂件来管理项⽬信息,配置脚本5、AMD CMD规范的区别 CommonJS和AMD都是JavaScript模块化规范 CMD依赖就近,⽽AMD依赖前置 CMD是延迟执⾏的,⽽AMD是提前执⾏的 AMD的API默认是⼀个当多个⽤,CMD的API严格区分,推崇职责单⼀6、如何判断当前脚本运⾏在浏览器还是node环境中 通过判断 Global 对象是否为 window ,如果不为window ,当前脚本没有运⾏在浏览器中7、简述同步和异步的区别,如何避免回调地狱 同步⽅法调⽤⼀旦开始,调⽤者必须等到⽅法调⽤返回后,才能继续后续的⾏为 异步⽅法调⽤⼀旦开始,⽅法调⽤就会⽴即返回,调⽤者就可以继续后续的操作。
⽽异步⽅法通常会在另外⼀个线程中,整个过程,不会阻碍调⽤者的⼯作 避免回调地狱: 1)Promise 2)async/await 3)generator 4)事件发布/监听模式8、⼏种常见模块化规范的简介 CommonJS规范主要⽤于服务端编程,加载模块是同步的,这并不适合在浏览器环境,因为同步意味着阻塞加载,浏览器资源是异步加载的 AMD规范在浏览器环境中异步加载模块,⽽且可以并⾏加载多个模块。
AMD规范与CMD规范的区别AMD规范与CMD规范的区别是什么?在⽐较之前,我们得先来了解下什么是AMD规范?什么是CMD规范?当然先申明⼀下,我个⼈也是总结下⽽已,也是⽹上看到的资料,⾃⼰总结下或者可以说整理下⽽已,供⼤家更深⼊的了解!因为我们都知道 AMD规范:是 RequireJS 在推⼴过程中对模块定义的规范化产出的,⽽CMD规范:是SeaJS 在推⼴过程中对模块定义的规范化产出的。
什么是CMD规范?在CMD中⼀个模块就是⼀个⽂件,如下代码所⽰://基本格式如:define(id, deps, factory)// ⽐如如下代码define('hello',['jQuery'],function(require, exports, module) {// 模块代码});define是⼀个全局函数,主要是⽤来定于模块的。
其中如上'hello'就是模块名称,['jquery']是依赖项,也可以依赖于多项可以如下写法['jquery','',''],分别⽤逗号隔开,其中上⾯的id(模块名称)和deps(被依赖项define(function(require, exports, module) {// 模块代码});那么如果我想在b.js代码⾥⾯要依赖于a.js的话,那么我可以直接这样写:define(function(require,exports,module){ var a = require('a')});但是注意:带有id 和 deps 是不属于CMD规范的。
所以在seaJS⾥⾯⼀般的写法是不带模块名称和依赖项的。
就是如上的代码格式。
下⾯看看 factory 在seajs⾥⾯ factory既可以是函数,对象或者字符串。
factory为对象字符串时候,表⽰该模块的接define({provinces: [{name: '上海',areas: ['浦东新区', '徐汇区']},{name: '江苏',cities: ['南京', '南通']}//.....]});假设这个⽂件名为china.js,那么如果某个模块需要这个数据,只需要:define(function(require,exports,module){ var china = require('./china');//在这⾥使⽤中国省市数据});当factory为函数时,表⽰该模块的构造⽅法,执⾏该构造⽅法,可以得到模块向外提供的接⼝。
I n t e r n a t i o n a l T e l e c o m m u n i c a t i o n U n i o n ITU-T G.984.2TELECOMMUNICATION STANDARDIZATION SECTOR OF ITU Amendment 1(02/2006)SERIES G: TRANSMISSION SYSTEMS AND MEDIA, DIGITAL SYSTEMS AND NETWORKSDigital sections and digital line system – Optical line systems for local and access networksGigabit-capable Passive Optical Networks(G-PON): Physical Media Dependent (PMD) layer specificationAmendment 1: New Appendix III – Industry best practice for 2.488 Gbit/s downstream,1.244 Gbit/s upstream G-PONITU-T Recommendation G.984.2 (2003) – Amendment 1ITU-T G-SERIES RECOMMENDATIONSTRANSMISSION SYSTEMS AND MEDIA, DIGITAL SYSTEMS AND NETWORKSFor further details, please refer to the list of ITU-T Recommendations.ITU-T Recommendation G.984.2Gigabit-capable Passive Optical Networks (G-PON):Physical Media Dependent (PMD) layer specificationAmendment 1New Appendix III – Industry best practice for 2.488 Gbit/s downstream,1.244 Gbit/s upstream G-PONSummaryThis amendment adds a new appendix to ITU-T Rec. G.984.2 that establishes the industry best practice optical budgets for the G-PON system operating at 2.488 Gbit/s downstream, 1.244 Gbit/s upstream.SourceAmendment 1 to ITU-T Recommendation G.984.2 (2003) was agreed on 17 February 2006 by ITU-T Study Group 15 (2005-2008).KeywordsG-PON, optical.ITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006) iFOREWORDThe International Telecommunication Union (ITU) is the United Nations specialized agency in the field of telecommunications. The ITU Telecommunication Standardization Sector (ITU-T) is a permanent organ of ITU. ITU-T is responsible for studying technical, operating and tariff questions and issuing Recommendations on them with a view to standardizing telecommunications on a worldwide basis.The World Telecommunication Standardization Assembly (WTSA), which meets every four years, establishes the topics for study by the ITU-T study groups which, in turn, produce Recommendations on these topics.The approval of ITU-T Recommendations is covered by the procedure laid down in WTSA Resolution 1.In some areas of information technology which fall within ITU-T's purview, the necessary standards are prepared on a collaborative basis with ISO and IEC.NOTEIn this Recommendation, the expression "Administration" is used for conciseness to indicate both a telecommunication administration and a recognized operating agency.Compliance with this Recommendation is voluntary. However, the Recommendation may contain certain mandatory provisions (to ensure e.g. interoperability or applicability) and compliance with the Recommendation is achieved when all of these mandatory provisions are met. The words "shall" or some other obligatory language such as "must" and the negative equivalents are used to express requirements. The use of such words does not suggest that compliance with the Recommendation is required of any party.INTELLECTUAL PROPERTY RIGHTSITU draws attention to the possibility that the practice or implementation of this Recommendation may involve the use of a claimed Intellectual Property Right. ITU takes no position concerning the evidence, validity or applicability of claimed Intellectual Property Rights, whether asserted by ITU members or others outside of the Recommendation development process.As of the date of approval of this Recommendation, ITU had not received notice of intellectual property, protected by patents, which may be required to implement this Recommendation. However, implementors are cautioned that this may not represent the latest information and are therefore strongly urged to consult the TSB patent database.© ITU 2006All rights reserved. No part of this publication may be reproduced, by any means whatsoever, without the prior written permission of ITU.ii ITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006)CONTENTSPage New Appendix III – Industry best practice for 2.488 Gbit/s downstream,1.244 Gbit/s upstream G-PON (1)III.1 Introduction (1)III.2 System applications (1)III.3 Optical specifications (1)III.4 Link budget (2)ITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006) iiiIntroductionThis amendment describes the recommended practical power budgets for systems described in the G.984 series that operate at the downstream rate of 2.488 Gbit/s and upstream rate of 1.244 Gbit/s. These budgets are optional extensions of the Recommendation, and reflect the observed practical optimum values for this particular system.iv ITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006)ITU-T Recommendation G.984.2Gigabit-capable Passive Optical Networks (G-PON):Physical Media Dependent (PMD) layer specificationAmendment 1New Appendix III – Industry best practice for 2.488 Gbit/s downstream,1.244 Gbit/s upstream G-PONIII.1 IntroductionThe widespread interest in the 2.4 Gbit/s downstream, 1.2 Gbit/s upstream G-PON system has provided increased visibility into the feasibility of loss budgets for this system. This appendix captures the industry best practices for this rate combination.The notable variations from the loss budgets found elsewhere in this Recommendation include: •overall loss budgets midway between class B and class C;•different value of optical path penalties;•the OLT must support FEC in the downstream.These variations can provide increased capabilities for operation of G-PON systems. Therefore, the budgets contained in this appendix are recommended over and above all others in this Recommendation for the 2.4/1.2 Gbit/s rate PON.III.2 System applicationsThere are currently two major applications for the G-PON system. The first is a full-service system with a video overlay. The second is a digital-only system without a video overlay. These two applications are diagrammed in Figure III.1.Figure III.1/G.984.2 – G-PON applicationsIII.3 Optical specificationsThe optical specifications for the OLT and ONU optics are given in Table III.1. This table refers to power levels measured at the interface points shown in Figure III.1, i.e., both types a (Video overlay) and b (Digital-only) systems. Specifically, any WDM filters external to the OLT or ONU equipment are considered part of the ODN. These specifications are meant to augment similarITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006) 1specifications found in Table 2 in the main body of the Recommendation. All other specifications found elsewhere in the table still apply.The ONU sensitivity can be achieved either using an APD without FEC, or a PIN with FEC. The choice is a matter of ONU implementation. The APD solution is seen as an immediately available option, while the PIN with FEC solution is a longer-term option that depends on the introduction of higher performance receiver circuitry. The OLT must support FEC in the downstream by having the capability of calculating and transmitting the FEC parity bytes in the downstream signal. The OLT equipment must also have the ability to activate or deactivate the downstream FEC feature by operations system command. The ONU can optionally support FEC decoding in the downstream, and in any specific instance the ONU can use the FEC parity at its own discretion.The optical penalty does not include any Raman impairment in the downstream wavelength. Any penalty due to this effect must be accounted for out of the link budget. However, in any system with appreciable Raman effect will also have a significant length of fibre. Because of the loss differential between 1490 nm and 1310 nm, it is anticipated that the Raman impairment will be compensated by the lower fibre loss at 1490 nm.Table III.1/G.984.2 – Optical power levels for the 2.4 Gbit/s downstream,1.2 Gbit/s upstream systemIII.4 Link budgetThe link budget is given in Table III.2. This budget covers all optical components between the OLT and ONU, including non-integrated WDM filters for the multiplex of video overlays and other enhancement band services, and must include any Raman impairment from the overlay signal.Table III.2/G.984.2 – Loss budgets for the G-PON system2ITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006)In comparison, the B-PON class B+ budgets recommended in ITU-T Rec. G.983.3/Amd.2 are shown in Table III.3. The G-PON budget is similar to the Video Overlay system in that it supports a 13-dB minimum loss, and it is similar to the digital-only budget in that it is symmetric and it supports a 28-dB maximum loss. It is theoretically possible that a PON that complies with the B-PON B+ budgets might not comply with the G-PON budget; however, such cases should be very rare in the actual deployed base of PONs. Therefore, the G-PON budget should be compatible with practically all deployed PONs.Table III.3/G.984.2 – Loss budgets for the B-PON G.983.3/Amd.2 systemsITU-T Rec. G.984.2 (2003)/Amd.1 (02/2006) 3Printed in SwitzerlandGeneva, 2006。
⾯试指南」JS模块化、组件化、⼯程化相关的15道⾯试题JS 模块化、组件化、⼯程化相关的 15 道⾯试题1.什么是模块化?2.简述模块化的发展历程?3.AMD、CMD、CommonJS 与 ES6 模块化的区别?4.它们是如何使⽤的?5.export 是什么?6.module.export、export 与 export defalut 有什么区别?7.什么是组件化?8.组件化的原则是什么?9.全局组件与局部组件的区别?10.如何注册⼀个全局组件,并使⽤它?11.局部组件⼜是如何注册并使⽤的?12.如何封装⼀个⾼复⽤的 Vue 前端组件?13.什么是前端⼯程化思想?14.⼯程化可以解决什么问题?15.是如何处理这些问题的?问:1.什么是模块化?答:将 JS 分割成不同职责的 JS,解耦功能,来⽤于解决全局变量污染、变量冲突、代码冗余、依赖关系难以维护等问题的⼀种 JS 管理思想,这就是模块化的过程。
问:2.简述模块化的发展历程?答:模块化的发展主要从最初的⽆模块化,发展到闭包式的 IIFE ⽴即执⾏解决模块化,到后来的 CommonJS、 AMD、CMD,直到 ES6 模块化规范的出现。
// jQuery风格的匿名⾃执⾏(function(window) {//代码window.jQuery = window.$ = jQuery; //通过给window添加属性⽽暴漏到全局})(window);问:3.AMD、CMD、CommonJS 与 ES6 模块化的区别?答:CommonJS 是 NodeJs 的⼀种模块同步加载规范,⼀个⽂件即是⼀个模块,使⽤时直接 require(),即可,但是不适⽤于客户端,因为加载模块的时候有可能出现‘假死’状况,必须等模块请求成功,加载完毕才可以执⾏调⽤的模块。
但是在服务期不存在这种状况。
AMD (Asynchronous Module Definition):异步模块加载机制。
js模块化编程之彻底弄懂CommonJS和AMDCMD!先回答我:为什么模块很重要?答:因为有了模块,我们就可以更⽅便地使⽤别⼈的代码,想要什么功能,就加载什么模块。
但是,这样做有⼀个前提,那就是⼤家必须以同样的⽅式编写模块,否则你有你的写法,我有我的写法,岂不是乱了套!于是下⾯三个模块规范出来了,这篇⽂章也出来了(拼出来的 {捂脸笑})。
JS中的模块规范(CommonJS,AMD,CMD),如果你听过js模块化这个东西,那么你就应该听过或CommonJS或AMD甚⾄是CMD这些规范咯,我也听过,但之前也真的是听听⽽已。
现在就看看吧,这些规范到底是啥东西,⼲嘛的。
本⽂包括这三个规范的来源及对应的产物的原理。
⼀、CommonJS1.⼀开始⼤家都认为JS是辣鸡,没什么⽤,官⽅定义的API只能构建基于浏览器的应⽤程序,逗我呢,这太狭隘了吧(⽤了个⾼端词,嘎嘎),CommonJS就按耐不住了,CommonJS API定义很多普通应⽤程序(主要指⾮浏览器的应⽤)使⽤的API,从⽽填补了这个空⽩。
它的终极⽬标是提供⼀个类似Python,Ruby和Java标准库。
这样的话,开发者可以使⽤CommonJS API编写应⽤程序,然后这些应⽤可以运⾏在不同的JavaScript解释器和不同的主机环境中。
在兼容CommonJS的系统中,你可以使⽤JavaScript开发以下程序:(1).服务器端JavaScript应⽤程序(2).命令⾏⼯具(3).图形界⾯应⽤程序(4).混合应⽤程序(如,Titanium或Adobe AIR)2009年,美国程序员Ryan Dahl创造了项⽬,将javascript语⾔⽤于服务器端编程。
这标志"Javascript模块化编程"正式诞⽣。
因为⽼实说,在浏览器环境下,没有模块也不是特别⼤的问题,毕竟⽹页程序的复杂性有限;但是在服务器端,⼀定要有模块,与操作系统和其他应⽤程序互动,否则根本没法编程。
AS/NZS 4665.1/Amdt 1/2009-02-27STANDARDS AUSTRALIA/STANDARDS NEW ZEALANDAmendment No. 1toAS/NZS 4665.1:2005Performance of external power suppliesPart 1: Test method and energy performance markREVISED TEXTThe 2005 edition of AS/NZS 4665.1 is amended as follows; the amendments should be inserted in the appropriate places.SUMMARY: This Amendment applies to the Preface, Clauses 1.1 and 1.3 and Appendices A, B and C. Published on 27 February 2009.Approved for publication in New Zealand on behalf of the Standards Council of New Zealand on 29 January 2009PrefaceIn the seventh paragraph, delete the second sentence and replace with the following: R egulatory authorities have advised that it is intended to mandate Part 2 of the Standard (AS/NZS 4665.2:2005) in regulations in Australia and New Zealand no earlier than 1 December 2008, except for marking requirements, which are intended to be mandated no earlier than 1 April 2009.Clause 1.1Add a new fourth paragraph as follows:Power supplies within the scope of AS/NZS 4879 or IEC 61347.2.13 are excluded from the scope of this Standard.Clause 1.3.3Replace ‘r.m.s.’ with ‘average’.Clause 1.3.8Add a new Clause 1.3.8 as follows:1.3.8 Family of models—Non user selectable output voltageA range of non user selectable single output models based on common technically equivalent components (typically switchmode), but each model may have a different output voltage. They may be sold under different brand names or model numbers or both. Each member of the family is included on a single test report and has the same energy performance mark, but may have a different output voltage.Clause 1.3.9Add a new Clause 1.3.9 as follows:1.3.9 Multi-switch model—User selectable output voltageA model with a single output that provides a range of user selectable output voltages. They may be sold under different brand names or model numbers or both. Test reports may AMDT No. 1 FEB2009 AMDT No. 1 FEB 2009AMDT No. 1 FEB2009AMDT No. 1 FEB 2009AMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .Clauses 1.3.8 to 1.3.15Renumber Clauses 1.3.8 to 1.3.15 as Clauses 1.3.10 to 1.3.17 respectively.Clause 1.3.18Add a new Clause 1.3.18 as follows: 1.3.18 Single model(s)One or more models using technically equivalent components with identical performance specifications having the same output voltage. They may be sold under different brand names or model numbers or both. Test reports may include one or more models having the same energy performance mark.Clauses 1.3.16 and 1.3.17Renumber Clauses 1.3.16 and 1.3.17 as Clauses 1.3.19 and 1.3.20 respectively.Paragraph A1Add new third and fourth paragraphs as follows:External power supplies, for Mark V only, with an input power greater than or equal to 100 W shall have a true power factor of 0.9 or greater at 100% of rated load when tested at 115 V, 60 Hz.Products tested for compliance with Mark V at both 115 V and 230 V shall meet the power factor requirement when tested at 115 V, but not when tested at 230 V.AMDT No. 1 FEB2009AMDT No. 1 FEB 2009 AMDT No. 1 FEB2009AMDT No. 1 FEB 2009 e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .Table A1Delete the Table and replace with the following:TABLE A1ENERGY PERFORMANCE REQUIREMENTS FOR EACH NUMERALNo load power consumptionrequirementsActive mode efficiency requirementsNameplate output power No load powerNameplate output power Mark(P no ) WW(P no ) WOutput specificationAverage active modeefficiencyI Used if it does not meet any of the following criteria 0 to <1 All ≥0.39 × P noII0 to <10 10 to ≤250 ≤0.75 ≤1.0 1 to <49 All ≥0.107 × L n (P no ) + 0.39 0 to 1All ≥0.490 × P no>1 to 49 All ≥0.090 × L n (P no ) + 0.490 to a maximum of 0.840 III 0 to <10 10 to ≤250≤0.5 ≤0.75>49 to 250 All ≥0.840 0 to 1All ≥0.500 × P no>1 to 51 All ≥0.090 × L n (P no ) + 0.500 to a maximum of 0.850 IV0 to <10 10 to ≤250≤0.5 ≤0.5>51 to 250All≥0.850AC-AC AC-DCOutput voltage<6 V andoutput current ≥0.550 A ≥0.497 × P no + 0.067 0 to 1Other models ≥0.480 × P no + 0.140 Output voltage <6 V andoutput current ≥0.550 A ≥0.0750 × L n (P no ) + 0.561 0 to <50≤0.5 ≤0.3>1 to 49Other models ≥0.0626 × L n (P no ) + 0.622Output voltage <6 V andoutput current ≥0.550 A ≥0.860 V50 to ≤250 ≤0.5 ≤0.5 >49 to 250Other models≥0.870VI – X Reserved for future useLEGEND:P no = nameplate output power of the EUT L n = the natural logarithm (base e)AMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .Paragraph A21 Insert a new Clause heading before the first paragraph as follows:A2.1 General2 Delete the Note and replace with the following:NOTE: Numerals VI to X are reserved for future use.3 Insert the following after Figure A1:A2.2 Single performance mark when tested at 115 V a.c., 230 V a.c. and240 V a.c. or has a single input voltage If the external power supply complies with the requirements of a single performance mark at both 115 V a.c. and 230 V a.c. or has a single input voltage, then the mark can be as shown in Figure A1. If only one mark is applied, then it shall be the lowest mark attained when tested at 115 V a.c. and 230 V a.c. A2.3 Dual markingIf the external power supply meets different energy performance for different a.c. supply voltages, then the external power supply may voluntarily be marked with its performance mark qualified by voltage at which it applies, with the appropriate voltage marked immediately beside the mark. Figure A2 provides an example of dual marking, where the external power supply meets performance Mark IV at 115 V a.c.and Mark III at 230 V a.c.FIGURE A2 EXAMPLE OF DUAL MARKINGA2.4 P erformance mark for models capable of multiple input voltages whentested at 230 V a.c. only If the external power supply is capable of multiple input voltages, but is tested and complies with the above requirements at 230 V a.c. only, then the mark shall bequalified with ‘230’ as per the examples in Figure A3.FIGURE A3 EXAMPLES FOR 230 V a.c. COMPLIANCE ONLYAMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .A2.5 P erformance mark for models capable of multiple input voltages whentested at 115 V a.c. only If the external power supply is capable of multiple input voltages, but is tested and complies with the above requirements at 115 V a.c. only, then the mark shall bequalified with ‘115’ as per the examples in Figure A4.FIGURE A4 EXAMPLES FOR 115 V a.c. COMPLIANCE ONLYAMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .Figure B1Delete Figure B1 and replace with the following:Does the EPS convert mains a.c.input voltage into one ELV output of a single voltage or user selectable voltage?Is the EPS in a housing that is separate from the end-use product it is intended to power?Does the EPS charge a battery?YESYESDo the batteries or battery pack physically attach directly to the EPS independently of the end-use product they power and with no interveningdevice?NODoes the EPS have a battery chemistry or type selector switch AND indicator light or state of charge meter?Does NOT meet the definition of an EPSDoes NOT meet the definition of an EPSMeets the definition ofan EPSYESNONOYESYESStar tNONOFIGURE B1 FLOWCHART FOR DEFINITION OF SINGLE OUTPUT EXTERNALPOWER SUPPLYAMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .Appendix CDelete Appendix C and replace with the following:APPENDIX CSAMPLE TEST REPORT(Informative)SINGLE OUTPUT EXTERNAL POWER SUPPLY TEST REPORTNameplate input voltageNameplate output voltageNameplate output currentNameplate output watts/VA230 V a.c. 5.0 1.0 5.0 115 V a.c. 5.0 1.0 5.0LAB INFORMATIONTest laboratory name XYZ Test Centre Test laboratory address 1 South St S ydney, N S W 2000 Country Australia Test technician(s) Joe Bloggs Date measured 14 July 2005 Test Standard used AS/NZS 4665.1:2005TEST INSTRUMENTSMake/Model Measurement Calibration date XYZ Model 1No Load 22 April 2005 ABC Model 2 Active Output 21 April 2005CONNECTIONS OR MODIFICATIONS TO THE INPUT AND/OR OUTPUT CORD a.c. input typeAS/NZS 3112 integrated plug Input cord length (mm) Not applicable—integrated plug Output cord length (mm) 1750Output plug typeSingle pin type Modification to connectors for testing NoneTEST SETUPTest report number 000123Manufacturer name Brand X Model ABC CountryChina Input power switchNot present Product powered (if known) Not known Output type d.c.Design typeNon user selectable output voltageNameplate input specifications 100 V – 240 V 50 Hz – 60 HzNameplate input current0.5 A – 0.3 AAMDT No. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .75%50%25%5%0%25%50%75%100%Actual fraction of output current4567832100%25%50%75%100%Input and output power vs Output current Actual fraction of output currentP o w e r (W )InputOutputInput vs Output power0.01.02.03.04.05.06.07.08.0Output power (W)I n p u t p o w e r (W )NOTE: Repeat the following table for minimum and maximum output voltage if applicable.No loadActive power valuesPercent of nameplate current 0% 25% 50% 75% 100% Average Output current (A) 0 0.248 0.498 0.747 1.001 — Output voltage (V) 5.07 5.024 5.003 4.981 4.959 — Output power (W) 0 1.244 2.492 3.721 4.966 — a.c. input current (A) 0.019 0.048 0.070 0.092 0.115 — a.c. input voltage (V) 114.9 114.9 114.9 114.9 114.9 — a.c. input power (W) 0.839 2.621 4.136 5.708 7.390 — Total harmonic distortion (THD ) 88.75% 86.91% 84.99% 83.29% 81.64% — True power factor 0.394 0.477 0.513 0.539 0.561 0.497 Power consumed by EUT (W) 0.839 1.377 1.644 1.987 2.425 — Efficiency — 47.46% 60.25% 65.19% 67.19% 60.02%FIGURE C1 MEASURED AND CALCULATED DATA AT 115 V 60 HzNo. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .75%50%25%5%0%25%50%75%100%Actual fraction of output current4567832100%25%50%75%100%Input and output power vs Output currentActual fraction of output currentP o w e r (W )InputOutputInput vs Output power0.01.02.03.04.05.06.07.08.0Output power (W)I n p u t p o w e r (W )NOTE: Repeat the following table for minimum and maximum output voltage if applicable.No loadActive power values Percent of nameplate current 0% 25% 50% 75% 100% Average Output current (A) 0 0.248 0.498 0.749 1.000 — Output voltage (V) 5.06 5.021 4.999 4.978 4.957 — Output power (W) 0 1.244 2.487 3.729 4.957 — a.c. input current (A) 0.018 0.041 0.052 0.064 0.076 — a.c. input voltage (V) 229.9 229.9 229.9 229.9 229.9 — a.c. input power (W) 1.360 3.703 4.983 6.395 7.927 — Total harmonic distortion (THD ) 86.49% 89.84% 89.48% 88.94% 88.30% — True power factor 0.324 0.396 0.417 0.435 0.451 0.405 Power consumed by EUT (W) 1.360 2.459 2.459 2.666 2.970 — Efficiency — 33.60% 49.92% 58.31% 62.53% 51.09%FIGURE C2 MEASURED AND CALCULATED DATA AT 230 V 50 HzNo. 1 FEB 2009e d t o M r s i d n e y y a n g o n 7 M a r c h 2009. P e r s o n a l u s e l i c e n c e o n l y . S t o r a g e , d i s t r i b u t i o n o r u s e o n n e t w o r k p r o h i b i t e d .。
最近在研究cmd和amd,在网上看到一篇不错的文章,整理下看看。
在JavaScript发展初期就是为了实现简单的页面交互逻辑,寥寥数语即可;如今CPU、浏览器性能得到了极大的提升,很多页面逻辑迁移到了客户端(表单验证等),随着web2.0时代的到来,Ajax技术得到广泛应用,jQuery等前端库层出不穷,前端代码日益膨胀这时候JavaScript作为嵌入式的脚本语言的定位动摇了,JavaScript却没有为组织代码提供任何明显帮助,甚至没有类的概念,更不用说模块(module)了,JavaScript极其简单的代码组织规范不足以驾驭如此庞大规模的代码模块既然JavaScript不能handle如此大规模的代码,我们可以借鉴一下其它语言是怎么处理大规模程序设计的,在Java中有一个重要带概念——package,逻辑上相关的代码组织到同一个包内,包内是一个相对独立的王国,不用担心命名冲突什么的,那么外部如果使用呢?直接import对应的package即可import java.util.ArrayList;遗憾的是JavaScript在设计时定位原因,没有提供类似的功能,开发者需要模拟出类似的功能,来隔离、组织复杂的JavaScript代码,我们称为模块化。
一个模块就是实现特定功能的文件,有了模块,我们就可以更方便地使用别人的代码,想要什么功能,就加载什么模块。
模块开发需要遵循一定的规范,各行其是就都乱套了规范形成的过程是痛苦的,前端的先驱在刀耕火种、茹毛饮血的阶段开始,发展到现在初具规模,简单了解一下这段不凡的历程函数封装我们在讲函数的时候提到,函数一个功能就是实现特定逻辑的一组语句打包,而且JavaScript的作用域就是基于函数的,所以把函数作为模块化的第一步是很自然的事情,在一个文件里面编写几个相关函数就是最开始的模块了function fn1(){statement}function fn2(){statement}∙1∙2∙3∙4∙5∙6∙7这样在需要的以后夹在函数所在文件,调用函数就可以了这种做法的缺点很明显:污染了全局变量,无法保证不与其他模块发生变量名冲突,而且模块成员之间没什么关系。
AMD规范1. AMD的由来前端技术虽然在不断发展之中,却一直没有质的飞跃。
除了已有的各大著名框架,比如Dojo,JQuery,ExtJs等等,很多公司也都有着自己的前端开发框架。
这些框架的使用效率以及开发质量在很大程度上都取决于开发者对其的熟悉程度,以及对JavaScript的熟悉程度,这也是为什么很多公司的技术带头人都喜欢开发一个自己的框架。
开发一个自己会用的框架并不难,但开发一个大家都喜欢的框架却很难。
从一个框架迁移到一个新的框架,开发者很有可能还会按照原有框架的思维去思考和解决问题。
这其中的一个重要原因就是JavaScript本身的灵活性:框架没办法绝对的约束你的行为,一件事情总可以用多种途径去实现,所以我们只能在方法学上去引导正确的实施方法。
庆幸的是,在这个层面上的软件方法学研究,一直有人在去不断的尝试和改进,CommonJS就是其中的一个重要组织。
他们提出了许多新的JavaScri pt架构方案和标准,希望能为前端开发提供银蛋,提供统一的指引。
AMD规范就是其中比较著名一个,全称是Asynchronous Module Definition,即异步模块加载机制。
从它的规范描述页面看,AMD很短也很简单,但它却完整描述了模块的定义,依赖关系,引用关系以及加载机制。
从它被requireJS,NodeJs,Dojo,JQuery使用也可以看出它具有很大的价值,没错,JQue ry近期也采用了AMD规范。
在这篇文章中,我们就将介绍AMD的性质,用法,优势以及应用场景。
从AMD中我们也能学习到如何在更高层面去设计自己的前端应用。
2. AMD是什么作为一个规范,只需定义其语法API,而不关心其实现。
AMD规范简单到只有一个API,即define函数:define([module-name?], [array-of-dependencies?], [module-factory-or-object]);其中:∙module-name: 模块标识,可以省略。
∙array-of-dependencies: 所依赖的模块,可以省略。
∙module-factory-or-object: 模块的实现,或者一个JavaScript对象。
从中可以看到,第一个参数和第二个参数都是可以省略的,第三个参数则是模块的具体实现本身。
后面将介绍在不同的应用场景下,他们会使用不同的参数组合。
从这个define函数AMD中的A:Asynchronous,我们也不难想到define函数具有的另外一个性质,异步性。
当define函数执行时,它首先会异步的去调用第二个参数中列出的依赖模块,当所有的模块被载入完成之后,如果第三个参数是一个回调函数则执行,然后告诉系统模块可用,也就通知了依赖于自己的模块自己已经可用。
如果对应到dojo1.6之前的实现,那么在功能上可以有如下对应关系:∙module-name: dojo.provide∙dependencies: dojo.requiremodule-factory: dojo.declare不同的是,在加载依赖项时,AMD用的是异步,而dojo.require是同步。
异步和同步的区别显而易见,前者不会阻塞浏览器,有更好的性能和灵活性。
而对于NodeJs这样的服务器端AMD,则模块载入无需阻塞服务器进程,同样提高了性能。
3. AMD实例:如何定义一个模块下面代码定义了一个alpha模块,并且依赖于内置的require,exports模块,以及外部的beta模块。
可以看到,第三个参数是回调函数,可以直接使用依赖的模块,他们按依赖声明顺序作为参数提供给回调函数。
这里的require函数让你能够随时去依赖一个模块,即取得模块的引用,从而即使模块没有作为参数定义,也能够被使用;exports是定义的alpha 模块的实体,在其上定义的任何属性和方法也就是alpha模块的属性和方法。
通过exports.verb = ...就是为alpha模块定义了一个verb方法。
例子中是简单调用了模块beta的verb方法。
define("alpha", ["require", "exports", "beta"], function (require, ex ports, beta) {exports.verb = function() {return beta.verb();//或者:return require("beta").verb();}});4. 匿名模块define 方法允许你省略第一个参数,这样就定义了一个匿名模块,这时候模块文件的文件名就是模块标识。
如果这个模块文件放在a.js中,那么a就是模块名。
可以在依赖项中用"a"来依赖于这个匿名模块。
这带来一个好处,就是模块是高度可重用的。
你拿来一个匿名模块,随便放在一个位置就可以使用它,模块名就是它的文件路径。
这也很好的符合了DRY(Don't Repeat Yourself)原则。
下面的代码就定义了一个依赖于alpha模块的匿名模块:define(["alpha"], function (alpha) {return {verb: function(){return alpha.verb() + 2;}};});5. 仅有一个参数的define前面提到,define的前两个参数都是可以省略的。
第三个参数有两种情况,一种是一个JavaScript对象,另一种是一个函数。
如果是一个对象,那么它可能是一个包含方法具有功能的一个对象;也有可能是仅提供数据。
后者和JSO N-P非常类似,因此AMD也可以认为包含了一个完整的JSON-P实现。
模块演变为一个简单的数据对象,这样的数据对象是高度可用的,而且因为是静态对象,它也是CDN友好的,可以提高JSON-P的性能。
考虑一个提供中国省市对应关系的JavaScript对象,如果以传统JSON-P的形式提供给客户端,它必须提供一个callback函数名,根据这个函数名动态生成返回数据,这使得标准JSON-P数据一定不是CDN 友好的。
但如果用AMD,这个数据文件就是如下的形式:define({provinces: [{name: '上海',areas: ['浦东新区', '徐汇区']},{name: '江苏',cities: ['南京', '南通']}//.....]});假设这个文件名为china.js,那么如果某个模块需要这个数据,只需要:define(['china', function(china){//在这里使用中国省市数据});通过这种方式,这个模块是真正高度可复用的,无论是用远程的,还是Copy到本地项目,都节约了开发时间和维护时间。
如果参数是一个函数,其用途之一是快速开发实现。
适用于较小型的应用,你无需提前关注自己需要什么模块,自己给谁用。
在函数中,可以随时require自己需要的模块。
例如:define(function(){var p = require('china');//使用china这个模块});即你省略了模块名,以及自己需要依赖的模块。
这不意味着你无需依赖于其他模块,而是可以让你在需要的时候去require这些模块。
define方法在执行的时候,会调用函数的toString方法,并扫描其中的re quire调用,提前帮助你载入这些模块,载入完成之后再执行。
这使得快速开发成为可能。
需要注意的一点是,Opera不能很好的支持函数的toString方法,因此,在浏览器中它的适用性并不是很强。
但如果你是通过build工具打包所有的JavaScript文件,这将不是问题,构建工具会帮助你扫描require并强制载入依赖的模块。
6. Dojo中的AMDDojo 在三月初正式发布了1.6版本,其中一个重要的变化就是引入了AMD机制,取代了原来的dojo.p rovide和dojo.require方法。
但是现在仍然保持了向后兼容性,你仍然可以用dojo.provide和dojo.r equire来定义和加载模块。
需要注意的是:在Dojo 1.6 中,针对AMD 的重构仍然属于一个过渡期的改动, 用户自己开发的AMD 模块还不能被Dojo 的加载器和Build 系统支持 . 1.6 中现有的编译系统对AMD的支持还非常局限。
如果你自己开发了AMD 格式的模块,并且你仍然在使用默认的Doj o 同步模块加载器,那么你必须严格遵循Dojo 模块的格式( 包括换行的格式) 来保证你自己的模块能够成功编译。
总结起来有以下三点:∙用传统的方法(dojo.require()/dojo.provide()) –这些模块,只能被Dojo 同步加载器加载,但可以被Dojo 编译系统(Build System )正确的编译∙用Dojo 同步加载器来加载AMD 格式(define ())模块–这些模块可以被正常的加载,并且可以被其他兼容AMD 格式的加载器加载 . 现在虽然Dojo1.6 还没有正式支持这种用法,但在目前的Dojo1.6 编译系统中,是可以正常工作的 . ( 前提是你必须严格遵循Dojo 模块定义的代码规范)∙使用第三方加载器来加载AMD 格式(define ())模块–模块可以被正常加载,并且可以被其他加载器所使用 . 这些模块可以使用RequireJS 或Backdraft 提供的编译系统正常编译,但是Dojo 还没有正式的测试过和其他加载器的兼容性 .以Calendar为例,用define方法来定义这个模块:define("dijit/Calendar",["dojo", "dijit", "text!dijit/templates/Calendar.html", "dojo/cldr/supplemental", "dojo/date", "dojo/date/locale","dijit/_Widget", "dijit/_Templated", "dijit/_CssStateMixin", "dijit/form/DropDownButton"],function(dojo, dijit) {dojo.declare("dijit.Calendar",[dijit._Widget, dijit._Templated, dijit._CssStateMixin], {...});return dijit.Calendar;});可以看到,模块标识就是模块文件的路径,模块本身一般都是dojo.declare定义的类。