├── 1. 概述 ├── index.js ├── assets │ └── 2019-12-13-10-39-18.png └── 课件.md ├── .gitignore ├── 4. 其他包管理器 ├── 4-3. pnpm │ ├── test.js │ ├── package.json │ └── 笔记.md ├── 4-4. [扩展]pnpm原理 │ ├── link │ ├── proj │ │ └── index.js │ ├── temp │ │ ├── b.js │ │ ├── article.txt │ │ └── sub │ │ │ └── a.js │ ├── link.txt │ ├── cache │ │ ├── b │ │ │ └── index.js │ │ └── a │ │ │ └── index.js │ ├── assets │ │ ├── 2019-12-31-16-29-21.png │ │ ├── 2019-12-31-16-29-43.png │ │ ├── 2019-12-31-16-30-25.png │ │ ├── 2019-12-31-16-33-59.png │ │ ├── 2019-12-31-16-46-57.png │ │ ├── 2019-12-31-17-50-59.png │ │ ├── 2019-12-31-18-09-53.png │ │ ├── 2019-12-31-18-14-31.png │ │ ├── 2019-12-31-18-19-48.png │ │ └── 2019-12-31-18-27-19.png │ └── 笔记.md ├── 4-5. bower │ ├── bower_components │ │ └── jquery │ │ │ ├── src │ │ │ ├── var │ │ │ │ ├── arr.js │ │ │ │ ├── document.js │ │ │ │ ├── getProto.js │ │ │ │ ├── push.js │ │ │ │ ├── class2type.js │ │ │ │ ├── concat.js │ │ │ │ ├── indexOf.js │ │ │ │ ├── rcheckableType.js │ │ │ │ ├── slice.js │ │ │ │ ├── pnum.js │ │ │ │ ├── fnToString.js │ │ │ │ ├── toString.js │ │ │ │ ├── hasOwn.js │ │ │ │ ├── documentElement.js │ │ │ │ ├── support.js │ │ │ │ ├── ObjectFunctionString.js │ │ │ │ ├── isWindow.js │ │ │ │ ├── rcssNum.js │ │ │ │ ├── rnothtmlwhite.js │ │ │ │ └── isFunction.js │ │ │ ├── selector.js │ │ │ ├── ajax │ │ │ │ ├── var │ │ │ │ │ ├── nonce.js │ │ │ │ │ ├── rquery.js │ │ │ │ │ └── location.js │ │ │ │ ├── parseXML.js │ │ │ │ ├── script.js │ │ │ │ ├── load.js │ │ │ │ ├── jsonp.js │ │ │ │ └── xhr.js │ │ │ ├── css │ │ │ │ ├── var │ │ │ │ │ ├── cssExpand.js │ │ │ │ │ ├── rboxStyle.js │ │ │ │ │ ├── rnumnonpx.js │ │ │ │ │ ├── getStyles.js │ │ │ │ │ ├── swap.js │ │ │ │ │ └── isHiddenWithinTree.js │ │ │ │ ├── hiddenVisibleSelectors.js │ │ │ │ ├── addGetHookIf.js │ │ │ │ ├── finalPropName.js │ │ │ │ ├── curCSS.js │ │ │ │ ├── adjustCSS.js │ │ │ │ ├── showHide.js │ │ │ │ └── support.js │ │ │ ├── data │ │ │ │ ├── var │ │ │ │ │ ├── dataPriv.js │ │ │ │ │ ├── dataUser.js │ │ │ │ │ └── acceptData.js │ │ │ │ └── Data.js │ │ │ ├── manipulation │ │ │ │ ├── var │ │ │ │ │ ├── rscriptType.js │ │ │ │ │ └── rtagName.js │ │ │ │ ├── setGlobalEval.js │ │ │ │ ├── getAll.js │ │ │ │ ├── _evalUrl.js │ │ │ │ ├── wrapMap.js │ │ │ │ ├── support.js │ │ │ │ └── buildFragment.js │ │ │ ├── traversing │ │ │ │ ├── var │ │ │ │ │ ├── rneedsContext.js │ │ │ │ │ ├── siblings.js │ │ │ │ │ └── dir.js │ │ │ │ └── findFilter.js │ │ │ ├── event │ │ │ │ ├── support.js │ │ │ │ ├── ajax.js │ │ │ │ ├── alias.js │ │ │ │ ├── focusin.js │ │ │ │ └── trigger.js │ │ │ ├── .eslintrc.json │ │ │ ├── core │ │ │ │ ├── readyException.js │ │ │ │ ├── nodeName.js │ │ │ │ ├── var │ │ │ │ │ └── rsingleTag.js │ │ │ │ ├── stripAndCollapse.js │ │ │ │ ├── toType.js │ │ │ │ ├── camelCase.js │ │ │ │ ├── support.js │ │ │ │ ├── isAttached.js │ │ │ │ ├── DOMEval.js │ │ │ │ ├── access.js │ │ │ │ ├── parseHTML.js │ │ │ │ ├── ready.js │ │ │ │ ├── ready-no-deferred.js │ │ │ │ └── init.js │ │ │ ├── attributes.js │ │ │ ├── effects │ │ │ │ ├── animatedSelector.js │ │ │ │ └── Tween.js │ │ │ ├── selector-sizzle.js │ │ │ ├── deferred │ │ │ │ └── exceptionHook.js │ │ │ ├── queue │ │ │ │ └── delay.js │ │ │ ├── exports │ │ │ │ ├── global.js │ │ │ │ └── amd.js │ │ │ ├── jquery.js │ │ │ ├── attributes │ │ │ │ ├── support.js │ │ │ │ ├── prop.js │ │ │ │ ├── attr.js │ │ │ │ ├── val.js │ │ │ │ └── classes.js │ │ │ ├── wrap.js │ │ │ ├── dimensions.js │ │ │ ├── deprecated.js │ │ │ ├── queue.js │ │ │ ├── serialize.js │ │ │ ├── data.js │ │ │ ├── traversing.js │ │ │ ├── callbacks.js │ │ │ └── selector-native.js │ │ │ ├── bower.json │ │ │ ├── .bower.json │ │ │ ├── LICENSE.txt │ │ │ ├── external │ │ │ └── sizzle │ │ │ │ └── LICENSE.txt │ │ │ └── README.md │ ├── bower.json │ └── index.html ├── 4-1. cnpm │ └── 笔记.md └── 4-2. nvm │ └── 笔记.md ├── 2. npm ├── 2-6. npm脚本 │ ├── scripts │ │ └── start.js │ ├── index.js │ ├── server.js │ ├── package.json │ └── 笔记.md ├── 2-3. 包的使用 │ ├── a │ │ └── index.js │ ├── sub │ │ └── test.js │ ├── test.js │ ├── index.js │ ├── package.json │ ├── package-lock.json │ └── 笔记.md ├── 2-9. 发布包 │ ├── test12345 │ │ ├── README.MD │ │ ├── index.js │ │ ├── package.json │ │ ├── package-lock.json │ │ └── LICENSE │ ├── another │ │ ├── index.js │ │ ├── package.json │ │ └── package-lock.json │ ├── 开源协议.md │ ├── assets │ │ └── 2019-12-18-16-03-02.png │ └── 笔记.md ├── 2-1. 包的安装 │ ├── assets │ │ └── 2019-12-16-10-25-13.png │ └── 笔记.md ├── 2-5. 语义版本 │ ├── assets │ │ └── 2019-12-17-15-17-47.png │ └── 笔记.md ├── 2-7. 运行环境配置 │ ├── test.js │ ├── index.js │ ├── package.json │ ├── 笔记.md │ └── package-lock.json ├── 2-4. 练习-简易数据爬虫 │ ├── 笔记.md │ ├── index.js │ ├── package.json │ ├── getMovies.js │ ├── movie.json │ └── package-lock.json ├── 2-2. 包配置 │ ├── subfolder │ │ └── package.json │ ├── package.json │ └── 笔记.md └── 2-8. 其他npm命令 │ ├── package.json │ ├── package-lock.json │ └── 笔记.md └── 3. yarn ├── 3-2. yarn的核心命令 ├── index.js ├── package.json └── 笔记.md ├── 3-3. yarn的特别礼物 ├── index.js ├── package.json └── 笔记.md └── 3-1. yarn简介 └── 笔记.md /1. 概述/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /4. 其他包管理器/4-3. pnpm/test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2. npm/2-6. npm脚本/scripts/start.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/link: -------------------------------------------------------------------------------- 1 | temp/sub -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/a/index.js: -------------------------------------------------------------------------------- 1 | module.exports = "a"; -------------------------------------------------------------------------------- /2. npm/2-6. npm脚本/index.js: -------------------------------------------------------------------------------- 1 | console.log("hello2") -------------------------------------------------------------------------------- /2. npm/2-6. npm脚本/server.js: -------------------------------------------------------------------------------- 1 | console.log("server") -------------------------------------------------------------------------------- /3. yarn/3-2. yarn的核心命令/index.js: -------------------------------------------------------------------------------- 1 | console.log("Hello") -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/proj/index.js: -------------------------------------------------------------------------------- 1 | require("b") -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/test12345/README.MD: -------------------------------------------------------------------------------- 1 | # 说明文档 2 | 3 | 啥也没有 -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/temp/b.js: -------------------------------------------------------------------------------- 1 | module.exports = "b" -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/link.txt: -------------------------------------------------------------------------------- 1 | 这是一篇文章 2 | 3 | this is a article 123 -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/sub/test.js: -------------------------------------------------------------------------------- 1 | var $ = require("jquery") 2 | 3 | console.log($) -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/temp/article.txt: -------------------------------------------------------------------------------- 1 | 这是一篇文章 2 | 3 | this is a article 123 -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/test.js: -------------------------------------------------------------------------------- 1 | var test = require("lodash/fp/add") 2 | 3 | console.log(test) -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/cache/b/index.js: -------------------------------------------------------------------------------- 1 | console.log("我是b模块"); 2 | module.exports = "b" -------------------------------------------------------------------------------- /4. 其他包管理器/4-3. pnpm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mocha": "^6.2.2" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/cache/a/index.js: -------------------------------------------------------------------------------- 1 | var b = require("b"); 2 | console.log("我是a模块,得到b模块的内容:", b); -------------------------------------------------------------------------------- /3. yarn/3-3. yarn的特别礼物/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function (...args) { 2 | return args.reduce((s, item) => s + item, 0); 3 | } -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/temp/sub/a.js: -------------------------------------------------------------------------------- 1 | console.log(__dirname); 2 | 3 | var b = require("../b") 4 | console.log("b模块的内容:", b); -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/arr.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return []; 5 | } ); 6 | -------------------------------------------------------------------------------- /1. 概述/assets/2019-12-13-10-39-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/1. 概述/assets/2019-12-13-10-39-18.png -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/another/index.js: -------------------------------------------------------------------------------- 1 | var func = require("testabcd1234") 2 | var newArr = func([45,7,0,false,"",21]) 3 | console.log(newArr) -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/selector.js: -------------------------------------------------------------------------------- 1 | define( [ "./selector-sizzle" ], function() { 2 | "use strict"; 3 | } ); 4 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/test12345/index.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | 3 | module.exports = function (arr) { 4 | return _.compact(arr); 5 | } -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/开源协议.md: -------------------------------------------------------------------------------- 1 | # 开源协议 2 | 3 | ![](assets/2019-12-18-16-03-02.png) 4 | 5 | 可以通过网站 http://choosealicense.online/appendix/ 选择协议,并复制协议内容 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/var/nonce.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return Date.now(); 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/var/rquery.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return ( /\?/ ); 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/document.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return window.document; 5 | } ); 6 | -------------------------------------------------------------------------------- /2. npm/2-1. 包的安装/assets/2019-12-16-10-25-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/2. npm/2-1. 包的安装/assets/2019-12-16-10-25-13.png -------------------------------------------------------------------------------- /2. npm/2-5. 语义版本/assets/2019-12-17-15-17-47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/2. npm/2-5. 语义版本/assets/2019-12-17-15-17-47.png -------------------------------------------------------------------------------- /2. npm/2-7. 运行环境配置/test.js: -------------------------------------------------------------------------------- 1 | //读取package.json文件中的版本号 2 | 3 | var config = require("./package.json") 4 | console.log(config.version) 5 | console.log(config.a) -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/assets/2019-12-18-16-03-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/2. npm/2-9. 发布包/assets/2019-12-18-16-03-02.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/var/location.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return window.location; 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/getProto.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return Object.getPrototypeOf; 5 | } ); 6 | -------------------------------------------------------------------------------- /3. yarn/3-3. yarn的特别礼物/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "lodash": "3.6.0" 4 | }, 5 | "devDependencies": { 6 | "mocha": "^6.2.2" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/push.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./arr" 3 | ], function( arr ) { 4 | "use strict"; 5 | 6 | return arr.push; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/class2type.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | // [[Class]] -> type pairs 5 | return {}; 6 | } ); 7 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/concat.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./arr" 3 | ], function( arr ) { 4 | "use strict"; 5 | 6 | return arr.concat; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/indexOf.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./arr" 3 | ], function( arr ) { 4 | "use strict"; 5 | 6 | return arr.indexOf; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/rcheckableType.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return ( /^(?:checkbox|radio)$/i ); 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/slice.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./arr" 3 | ], function( arr ) { 4 | "use strict"; 5 | 6 | return arr.slice; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-29-21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-29-21.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-29-43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-29-43.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-30-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-30-25.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-33-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-33-59.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-46-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-16-46-57.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-17-50-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-17-50-59.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-09-53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-09-53.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-14-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-14-31.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-19-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-19-48.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-27-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-PackageManager/HEAD/4. 其他包管理器/4-4. [扩展]pnpm原理/assets/2019-12-31-18-27-19.png -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/cssExpand.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return [ "Top", "Right", "Bottom", "Left" ]; 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/data/var/dataPriv.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../Data" 3 | ], function( Data ) { 4 | "use strict"; 5 | 6 | return new Data(); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/data/var/dataUser.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../Data" 3 | ], function( Data ) { 4 | "use strict"; 5 | 6 | return new Data(); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/pnum.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/fnToString.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./hasOwn" 3 | ], function( hasOwn ) { 4 | "use strict"; 5 | 6 | return hasOwn.toString; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/var/rscriptType.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return ( /^$|^module$|\/(?:java|ecma)script/i ); 5 | } ); 6 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/toString.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./class2type" 3 | ], function( class2type ) { 4 | "use strict"; 5 | 6 | return class2type.toString; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/hasOwn.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./class2type" 3 | ], function( class2type ) { 4 | "use strict"; 5 | 6 | return class2type.hasOwnProperty; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/documentElement.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./document" 3 | ], function( document ) { 4 | "use strict"; 5 | 6 | return document.documentElement; 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/support.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | // All support tests are defined in their respective modules. 5 | return {}; 6 | } ); 7 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/ObjectFunctionString.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./fnToString" 3 | ], function( fnToString ) { 4 | "use strict"; 5 | 6 | return fnToString.call( Object ); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/rboxStyle.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./cssExpand" 3 | ], function( cssExpand ) { 4 | "use strict"; 5 | 6 | return new RegExp( cssExpand.join( "|" ), "i" ); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/isWindow.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return function isWindow( obj ) { 5 | return obj != null && obj === obj.window; 6 | }; 7 | 8 | } ); 9 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/rnumnonpx.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../../var/pnum" 3 | ], function( pnum ) { 4 | "use strict"; 5 | 6 | return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/traversing/var/rneedsContext.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../../core", 3 | "../../selector" 4 | ], function( jQuery ) { 5 | "use strict"; 6 | 7 | return jQuery.expr.match.needsContext; 8 | } ); 9 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/rcssNum.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/pnum" 3 | ], function( pnum ) { 4 | 5 | "use strict"; 6 | 7 | return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 8 | 9 | } ); 10 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/event/support.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/support" 3 | ], function( support ) { 4 | 5 | "use strict"; 6 | 7 | support.focusin = "onfocusin" in window; 8 | 9 | return support; 10 | 11 | } ); 12 | -------------------------------------------------------------------------------- /3. yarn/3-2. yarn的核心命令/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter3", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "scripts": { 7 | "abc": "dir", 8 | "start": "node index.js" 9 | }, 10 | "dependencies": {} 11 | } 12 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/笔记.md: -------------------------------------------------------------------------------- 1 | # 简易数据爬虫 2 | 3 | 将豆瓣电影的电影数据抓取下来,保存到本地文件 movie.json 中 4 | 5 | 需要用到的包: 6 | 7 | 1. axios:专门用于在各种环境中发送网络请求,并获取到服务器响应结果 8 | 2. cheerio:jquery的核心逻辑包,支持所有环境,可用于讲一个html字符串转换成为jquery对象,并通过jquery对象完成后续操作 9 | 3. fs:node核心模块,专门用于文件处理 10 | - fs.writeFile(文件名, 数据) -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | 4 | "extends": "../.eslintrc-browser.json", 5 | 6 | "overrides": [ 7 | { 8 | "files": "wrapper.js", 9 | "globals": { 10 | "jQuery": false 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/index.js: -------------------------------------------------------------------------------- 1 | var getMovies = require("./getMovies") 2 | var fs = require("fs"); 3 | 4 | 5 | getMovies().then(movies => { 6 | var json = JSON.stringify(movies); 7 | fs.writeFile("movie.json", json, function () { 8 | console.log("成功!") 9 | }); 10 | }) -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/rnothtmlwhite.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | // Only count HTML whitespace 5 | // Other whitespace should count in values 6 | // https://infra.spec.whatwg.org/#ascii-whitespace 7 | return ( /[^\x20\t\r\n\f]+/g ); 8 | } ); 9 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/readyException.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | "use strict"; 6 | 7 | jQuery.readyException = function( error ) { 8 | window.setTimeout( function() { 9 | throw error; 10 | } ); 11 | }; 12 | 13 | } ); 14 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ] 14 | } -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/nodeName.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | function nodeName( elem, name ) { 6 | 7 | return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 8 | 9 | }; 10 | 11 | return nodeName; 12 | 13 | } ); 14 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-1. cnpm/笔记.md: -------------------------------------------------------------------------------- 1 | # cnpm 2 | 3 | > 官网地址:https://npm.taobao.org/ 4 | 5 | 为解决国内用户连接npm registry缓慢的问题,淘宝搭建了自己的registry,即淘宝npm镜像源 6 | 7 | 过去,npm没有提供修改registry的功能,因此,淘宝提供了一个CLI工具即cnpm,它支持除了```npm publish```以外的所有命令,只不过连接的是淘宝镜像源 8 | 9 | 如今,npm已经支持修改registry了,可能cnpm唯一的作用就是和npm共存,即如果要使用官方源,则使用npm,如果使用淘宝源,则使用cnpm -------------------------------------------------------------------------------- /2. npm/2-2. 包配置/subfolder/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subfolder", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/index.js: -------------------------------------------------------------------------------- 1 | // var _ = require("lodash"); 2 | 3 | // console.log(_) 4 | // // var arr = _.compact([1, 3, 0, "", false, 5]) 5 | 6 | // // console.log(arr) 7 | 8 | // 首先,查看当前目录是否有 a.js 9 | // 把a当作文件夹,并且,把该文件夹当作一个包,看该包中是否有package.json文件,读取main字段。。。。 10 | var a = require("./a"); 11 | 12 | console.log(a) -------------------------------------------------------------------------------- /2. npm/2-7. 运行环境配置/index.js: -------------------------------------------------------------------------------- 1 | var a = "没有环境变量"; 2 | console.log(process.env.NODE_ENV) 3 | if(process.env.NODE_ENV === "development"){ 4 | a = "开发环境" 5 | } 6 | else if(process.env.NODE_ENV === "production"){ 7 | a = "生产环境" 8 | } 9 | else if(process.env.NODE_ENV === "test"){ 10 | a = "测试环境" 11 | } 12 | console.log(a) -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/var/rsingleTag.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | // rsingleTag matches a string consisting of a single HTML element with no attributes 5 | // and captures the element's name 6 | return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 7 | } ); 8 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./attributes/attr", 4 | "./attributes/prop", 5 | "./attributes/classes", 6 | "./attributes/val" 7 | ], function( jQuery ) { 8 | 9 | "use strict"; 10 | 11 | // Return jQuery for attributes-only inclusion 12 | return jQuery; 13 | } ); 14 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/笔记.md: -------------------------------------------------------------------------------- 1 | # 发布包 2 | 3 | ## 准备工作 4 | 5 | 1. 移除淘宝镜像源 6 | 2. 到npm官网注册一个账号,并完成邮箱认证 7 | 3. 本地使用 npm cli 进行登录 8 | 1. 使用命令```npm login```登录 9 | 2. 使用命令```npm whoami```查看当前登录的账号 10 | 3. 使用命令```npm logout```注销 11 | 4. 创建工程根目录 12 | 5. 使用npm init进行初始化 13 | 14 | ## 发布 15 | 16 | 1. 开发 17 | 2. 确定版本 18 | 3. 使用命令```npm publish```完成发布 -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "lodash": "^4.17.15" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/another/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "another", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "testabcd1234": "^1.0.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/traversing/var/siblings.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | return function( n, elem ) { 6 | var matched = []; 7 | 8 | for ( ; n; n = n.nextSibling ) { 9 | if ( n.nodeType === 1 && n !== elem ) { 10 | matched.push( n ); 11 | } 12 | } 13 | 14 | return matched; 15 | }; 16 | 17 | } ); 18 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "axios": "^0.19.0", 13 | "cheerio": "^1.0.0-rc.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/effects/animatedSelector.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../selector", 4 | "../effects" 5 | ], function( jQuery ) { 6 | 7 | "use strict"; 8 | 9 | jQuery.expr.pseudos.animated = function( elem ) { 10 | return jQuery.grep( jQuery.timers, function( fn ) { 11 | return elem === fn.elem; 12 | } ).length; 13 | }; 14 | 15 | } ); 16 | -------------------------------------------------------------------------------- /2. npm/2-6. npm脚本/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chaper2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon index.js", 8 | "trick": "chrome https://www.baidu.com" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "nodemon": "^2.0.2" 14 | } 15 | } -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "lodash": { 8 | "version": "4.17.15", 9 | "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz", 10 | "integrity": "sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /2. npm/2-8. 其他npm命令/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "jquery": "3.4.1", 13 | "lodash": "^2.4.2" 14 | }, 15 | "devDependencies": {} 16 | } 17 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/var/rtagName.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | // rtagName captures the name from the first start tag in a string of HTML 5 | // https://html.spec.whatwg.org/multipage/syntax.html#tag-open-state 6 | // https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state 7 | return ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); 8 | } ); 9 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/test12345/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testabcd1234", 3 | "version": "1.0.1", 4 | "description": "this is test package", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "test" 11 | ], 12 | "author": "bangbangji <2782170452@qq.com>", 13 | "license": "MIT", 14 | "dependencies": { 15 | "lodash": "^4.17.15" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/test12345/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test12345", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "lodash": { 8 | "version": "4.17.15", 9 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", 10 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/hiddenVisibleSelectors.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../selector" 4 | ], function( jQuery ) { 5 | 6 | "use strict"; 7 | 8 | jQuery.expr.pseudos.hidden = function( elem ) { 9 | return !jQuery.expr.pseudos.visible( elem ); 10 | }; 11 | jQuery.expr.pseudos.visible = function( elem ) { 12 | return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 13 | }; 14 | 15 | } ); 16 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "4-5. bower", 3 | "homepage": "https://github.com/DuYi-Edu/DuYi-PackageManager", 4 | "authors": [ 5 | "yuanjin " 6 | ], 7 | "description": "", 8 | "main": "", 9 | "license": "MIT", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "test", 15 | "tests" 16 | ], 17 | "dependencies": { 18 | "jquery": "^3.4.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/data/var/acceptData.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | /** 6 | * Determines whether an object can have data 7 | */ 8 | return function( owner ) { 9 | 10 | // Accepts only: 11 | // - Node 12 | // - Node.ELEMENT_NODE 13 | // - Node.DOCUMENT_NODE 14 | // - Object 15 | // - Any 16 | return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 17 | }; 18 | 19 | } ); 20 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/stripAndCollapse.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/rnothtmlwhite" 3 | ], function( rnothtmlwhite ) { 4 | "use strict"; 5 | 6 | // Strip and collapse whitespace according to HTML spec 7 | // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 8 | function stripAndCollapse( value ) { 9 | var tokens = value.match( rnothtmlwhite ) || []; 10 | return tokens.join( " " ); 11 | } 12 | 13 | return stripAndCollapse; 14 | } ); 15 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-2. nvm/笔记.md: -------------------------------------------------------------------------------- 1 | # nvm 2 | 3 | nvm并非包管理器,它是用于管理多个node版本的工具 4 | 5 | 在实际的开发中,可能会出现多个项目分别使用的是不同的node版本,在这种场景下,管理不同的node版本就显得尤为重要 6 | 7 | nvm就是用于切换版本的一个工具 8 | 9 | ## 下载和安装 10 | 11 | 最新版下载地址:https://github.com/coreybutler/nvm-windows/releases 12 | 13 | 下载nvm-setup.zip后,直接安装 14 | 15 | ## 使用nvm 16 | 17 | nvm提供了CLI工具,用于管理node版本 18 | 19 | 在终端中输入nvm,以查看各种可用命令 20 | 21 | > 为了加快下载速度,建议设置淘宝镜像 22 | > node淘宝镜像:https://npm.taobao.org/mirrors/node/ 23 | > npm淘宝镜像:https://npm.taobao.org/mirrors/npm/ -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/event/ajax.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../event" 4 | ], function( jQuery ) { 5 | 6 | "use strict"; 7 | 8 | // Attach a bunch of functions for handling common AJAX events 9 | jQuery.each( [ 10 | "ajaxStart", 11 | "ajaxStop", 12 | "ajaxComplete", 13 | "ajaxError", 14 | "ajaxSuccess", 15 | "ajaxSend" 16 | ], function( i, type ) { 17 | jQuery.fn[ type ] = function( fn ) { 18 | return this.on( type, fn ); 19 | }; 20 | } ); 21 | 22 | } ); 23 | -------------------------------------------------------------------------------- /2. npm/2-7. 运行环境配置/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "cross-env NODE_ENV=development node index.js", 8 | "build": "cross-env NODE_ENV=production node index.js", 9 | "test": "cross-env NODE_ENV=test node index.js" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "cross-env": "^6.0.3" 15 | }, 16 | "a": 123 17 | } -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/toType.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/class2type", 3 | "../var/toString" 4 | ], function( class2type, toString ) { 5 | 6 | "use strict"; 7 | 8 | function toType( obj ) { 9 | if ( obj == null ) { 10 | return obj + ""; 11 | } 12 | 13 | // Support: Android <=2.3 only (functionish RegExp) 14 | return typeof obj === "object" || typeof obj === "function" ? 15 | class2type[ toString.call( obj ) ] || "object" : 16 | typeof obj; 17 | } 18 | 19 | return toType; 20 | } ); 21 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/traversing/var/dir.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../../core" 3 | ], function( jQuery ) { 4 | 5 | "use strict"; 6 | 7 | return function( elem, dir, until ) { 8 | var matched = [], 9 | truncate = until !== undefined; 10 | 11 | while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 12 | if ( elem.nodeType === 1 ) { 13 | if ( truncate && jQuery( elem ).is( until ) ) { 14 | break; 15 | } 16 | matched.push( elem ); 17 | } 18 | } 19 | return matched; 20 | }; 21 | 22 | } ); 23 | -------------------------------------------------------------------------------- /2. npm/2-6. npm脚本/笔记.md: -------------------------------------------------------------------------------- 1 | # npm 脚本 (npm scripts) 2 | 3 | 在开发的过程中,我们可能会反复使用很多的 CLI 命令,例如: 4 | 5 | - 启动工程命令(node 或 一些第三方包提供的CLI命令) 6 | - 部署工程命令(一些第三方包提供的CLI命令) 7 | - 测试工程命令(一些第三方包提供的CLI命令) 8 | 9 | 这些命令纷繁复杂,根据第三方包的不同命令也会不一样,非常难以记忆 10 | 11 | 于是,npm 非常贴心的支持了脚本,只需要在 package.json 中配置 scripts 字段,即可配置各种脚本名称 12 | 13 | 之后,我们就可以运行简单的指令来完成各种操作了 14 | 15 | 运行方式是 ```npm run 脚本名称``` 16 | 17 | 不仅如此,npm 还对某些常用的脚本名称进行了简化,下面的脚本名称是不需要使用run的: 18 | 19 | - start 20 | - stop 21 | - test 22 | 23 | 一些细节: 24 | 25 | - 脚本中可以省略npx 26 | - start脚本有默认值:node server.js -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/getStyles.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return function( elem ) { 5 | 6 | // Support: IE <=11 only, Firefox <=30 (#15098, #14150) 7 | // IE throws on elements created in popups 8 | // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 9 | var view = elem.ownerDocument.defaultView; 10 | 11 | if ( !view || !view.opener ) { 12 | view = window; 13 | } 14 | 15 | return view.getComputedStyle( elem ); 16 | }; 17 | } ); 18 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/var/isFunction.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | "use strict"; 3 | 4 | return function isFunction( obj ) { 5 | 6 | // Support: Chrome <=57, Firefox <=52 7 | // In some browsers, typeof returns "function" for HTML elements 8 | // (i.e., `typeof document.createElement( "object" ) === "function"`). 9 | // We don't want to classify *any* DOM node as a function. 10 | return typeof obj === "function" && typeof obj.nodeType !== "number"; 11 | }; 12 | 13 | } ); 14 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/setGlobalEval.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../data/var/dataPriv" 3 | ], function( dataPriv ) { 4 | 5 | "use strict"; 6 | 7 | // Mark scripts as having already been evaluated 8 | function setGlobalEval( elems, refElements ) { 9 | var i = 0, 10 | l = elems.length; 11 | 12 | for ( ; i < l; i++ ) { 13 | dataPriv.set( 14 | elems[ i ], 15 | "globalEval", 16 | !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 17 | ); 18 | } 19 | } 20 | 21 | return setGlobalEval; 22 | } ); 23 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/selector-sizzle.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "../external/sizzle/dist/sizzle" 4 | ], function( jQuery, Sizzle ) { 5 | 6 | "use strict"; 7 | 8 | jQuery.find = Sizzle; 9 | jQuery.expr = Sizzle.selectors; 10 | 11 | // Deprecated 12 | jQuery.expr[ ":" ] = jQuery.expr.pseudos; 13 | jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 14 | jQuery.text = Sizzle.getText; 15 | jQuery.isXMLDoc = Sizzle.isXML; 16 | jQuery.contains = Sizzle.contains; 17 | jQuery.escapeSelector = Sizzle.escape; 18 | 19 | } ); 20 | -------------------------------------------------------------------------------- /2. npm/2-3. 包的使用/笔记.md: -------------------------------------------------------------------------------- 1 | # 包的使用 2 | 3 | nodejs 对 npm 支持非常良好 4 | 5 | 当使用 nodejs 导入模块时,如果模块路径不是以 ./ 或 ../ 开头,则 node 会认为导入的模块来自于 node_modules 目录,例如: 6 | 7 | ```js 8 | var _ = require("lodash"); 9 | ``` 10 | 11 | 它首先会从当前目录的以下位置寻找文件 12 | 13 | ```shell 14 | node_modules/lodash.js 15 | node_modules/lodash/入口文件 16 | ``` 17 | 18 | 若当前目录没有这样的文件,则会回溯到上级目录按照同样的方式查找 19 | 20 | 如果到顶级目录都无法找到文件,则抛出错误 21 | 22 | 上面提到的入口文件按照以下规则确定 23 | 24 | 1. 查看导入包的package.json文件,读取main字段作为入口文件 25 | 2. 若不包含main字段,则使用index.js作为入口文件 26 | 27 | > 入口文件的规则同样适用于自己工程中的模块 28 | > 在 node 中,还可以手动指定路径来导入相应的文件,这种情况比较少见 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/swap.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | // A method for quickly swapping in/out CSS properties to get correct calculations. 6 | return function( elem, options, callback, args ) { 7 | var ret, name, 8 | old = {}; 9 | 10 | // Remember the old values, and insert the new ones 11 | for ( name in options ) { 12 | old[ name ] = elem.style[ name ]; 13 | elem.style[ name ] = options[ name ]; 14 | } 15 | 16 | ret = callback.apply( elem, args || [] ); 17 | 18 | // Revert the old values 19 | for ( name in options ) { 20 | elem.style[ name ] = old[ name ]; 21 | } 22 | 23 | return ret; 24 | }; 25 | 26 | } ); 27 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "3.4.1", 16 | "_release": "3.4.1", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "3.4.1", 20 | "commit": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d" 21 | }, 22 | "_source": "https://github.com/jquery/jquery-dist.git", 23 | "_target": "^3.4.1", 24 | "_originalSource": "jquery", 25 | "_direct": true 26 | } -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/camelCase.js: -------------------------------------------------------------------------------- 1 | define( [], function() { 2 | 3 | "use strict"; 4 | 5 | // Matches dashed string for camelizing 6 | var rmsPrefix = /^-ms-/, 7 | rdashAlpha = /-([a-z])/g; 8 | 9 | // Used by camelCase as callback to replace() 10 | function fcamelCase( all, letter ) { 11 | return letter.toUpperCase(); 12 | } 13 | 14 | // Convert dashed to camelCase; used by the css and data modules 15 | // Support: IE <=9 - 11, Edge 12 - 15 16 | // Microsoft forgot to hump their vendor prefix (#9572) 17 | function camelCase( string ) { 18 | return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 19 | } 20 | 21 | return camelCase; 22 | 23 | } ); 24 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/addGetHookIf.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | function addGetHookIf( conditionFn, hookFn ) { 6 | 7 | // Define the hook, we'll check on the first run if it's really needed. 8 | return { 9 | get: function() { 10 | if ( conditionFn() ) { 11 | 12 | // Hook not needed (or it's not possible to use it due 13 | // to missing dependency), remove it. 14 | delete this.get; 15 | return; 16 | } 17 | 18 | // Hook needed; redefine it so that the support test is not executed again. 19 | return ( this.get = hookFn ).apply( this, arguments ); 20 | } 21 | }; 22 | } 23 | 24 | return addGetHookIf; 25 | 26 | } ); 27 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/parseXML.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | "use strict"; 6 | 7 | // Cross-browser xml parsing 8 | jQuery.parseXML = function( data ) { 9 | var xml; 10 | if ( !data || typeof data !== "string" ) { 11 | return null; 12 | } 13 | 14 | // Support: IE 9 - 11 only 15 | // IE throws on parseFromString with invalid input. 16 | try { 17 | xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 18 | } catch ( e ) { 19 | xml = undefined; 20 | } 21 | 22 | if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 23 | jQuery.error( "Invalid XML: " + data ); 24 | } 25 | return xml; 26 | }; 27 | 28 | return jQuery.parseXML; 29 | 30 | } ); 31 | -------------------------------------------------------------------------------- /2. npm/2-7. 运行环境配置/笔记.md: -------------------------------------------------------------------------------- 1 | # 运行环境配置 2 | 3 | 我们书写的代码一般有三种运行环境: 4 | 5 | 1. 开发环境 6 | 2. 生产环境 7 | 3. 测试环境 8 | 9 | 有的时候,我们可能需要在 node 代码中根据不同的环境做出不同的处理 10 | 11 | 如何优雅的让 node 知道处于什么环境,是极其重要的 12 | 13 | 通常我们使用如下的处理方式: 14 | 15 | node中有一个全局变量 global (可以类比浏览器环境的window),该变量是一个对象,对象中的所有属性均可以直接使用 16 | 17 | global有一个属性是process,该属性是一个对象,包含了当前运行node程序的计算机的很多信息,其中有一个信息是env,是一个对象,包含了计算机中所有的系统变量 18 | 19 | 通常,我们通过系统变量 NODE_ENV 的值,来判定node程序处于何种环境 20 | 21 | 有两种方式设置 NODE_ENV 的值 22 | 23 | 1. 永久设置 24 | 2. 临时设置 25 | 26 | 我们一般使用临时设置 27 | 28 | 因此,我们可以配置 scripts 脚本,在设置好了 NODE_ENV 后启动程序 29 | 30 | > 为了避免不同系统的设置方式的差异,可以使用第三方库 cross-env 对环境变量进行设置 31 | 32 | ## 在node中读取package.json 33 | 34 | 有的时候,我们可能在 package.json 中配置一些自定义的字段,这些字段需要在node中读取 35 | 36 | 在node 中,可以直接导入一个json格式的文件,它会自动将其转换为js对象 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/support.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/document", 3 | "../var/support" 4 | ], function( document, support ) { 5 | 6 | "use strict"; 7 | 8 | // Support: Safari 8 only 9 | // In Safari 8 documents created via document.implementation.createHTMLDocument 10 | // collapse sibling forms: the second one becomes a child of the first one. 11 | // Because of that, this security measure has to be disabled in Safari 8. 12 | // https://bugs.webkit.org/show_bug.cgi?id=137337 13 | support.createHTMLDocument = ( function() { 14 | var body = document.implementation.createHTMLDocument( "" ).body; 15 | body.innerHTML = "
"; 16 | return body.childNodes.length === 2; 17 | } )(); 18 | 19 | return support; 20 | } ); 21 | -------------------------------------------------------------------------------- /2. npm/2-8. 其他npm命令/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "jquery": { 8 | "version": "3.4.1", 9 | "resolved": "https://registry.npm.taobao.org/jquery/download/jquery-3.4.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjquery%2Fdownload%2Fjquery-3.4.1.tgz", 10 | "integrity": "sha1-cU8fjZ3eS9+lV2S6N+8hRjDYDvI=" 11 | }, 12 | "lodash": { 13 | "version": "2.4.2", 14 | "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-2.4.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-2.4.2.tgz", 15 | "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/another/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "another", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "lodash": { 8 | "version": "4.17.15", 9 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", 10 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" 11 | }, 12 | "testabcd1234": { 13 | "version": "1.0.1", 14 | "resolved": "https://registry.npmjs.org/testabcd1234/-/testabcd1234-1.0.1.tgz", 15 | "integrity": "sha512-CqPtJMkvuEfQCzhQo5wRxgfuWhqhFR9qemtEVU8cWOIV5KvQTX/5ZLU17vtFMoGpPD+ZDVP0+UY+O0LNgaWmxg==", 16 | "requires": { 17 | "lodash": "^4.17.15" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /3. yarn/3-2. yarn的核心命令/笔记.md: -------------------------------------------------------------------------------- 1 | # yarn 的核心命令 2 | 3 | 1. **初始化** 4 | 5 | 初始化:```yarn init [--yes/-y]``` 6 | 7 | 2. **安装** 8 | 9 | 添加指定包:```yarn [global] add package-name [--dev/-D] [--exact/-E]``` 10 | 11 | 安装package.json中的所有依赖:```yarn install [--production/--prod]``` 12 | 13 | 3. **脚本和本地CLI** 14 | 15 | 运行脚本:```yarn run 脚本名``` 16 | 17 | > start、stop、test可以省略run 18 | 19 | 运行本地安装的CLI:```yarn run CLI名``` 20 | 21 | 4. **查询** 22 | 23 | 查看bin目录:```yarn [global] bin``` 24 | 25 | 查询包信息:```yarn info 包名 [子字段]``` 26 | 27 | 列举已安装的依赖:```yarn [global] list [--depth=依赖深度]``` 28 | 29 | > yarn的list命令和npm的list不同,yarn输出的信息更加丰富,包括顶级目录结构、每个包的依赖版本号 30 | 31 | 5. **更新** 32 | 33 | 列举需要更新的包:```yarn outdated``` 34 | 35 | 更新包:```yarn [global] upgrade [包名]``` 36 | 37 | 6. **卸载** 38 | 39 | 卸载包:```yarn remove 包名``` -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/deferred/exceptionHook.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../deferred" 4 | ], function( jQuery ) { 5 | 6 | "use strict"; 7 | 8 | // These usually indicate a programmer mistake during development, 9 | // warn about them ASAP rather than swallowing them by default. 10 | var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 11 | 12 | jQuery.Deferred.exceptionHook = function( error, stack ) { 13 | 14 | // Support: IE 8 - 9 only 15 | // Console exists when dev tools are open, which can happen at any time 16 | if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 17 | window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); 18 | } 19 | }; 20 | 21 | } ); 22 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/queue/delay.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../queue", 4 | "../effects" // Delay is optional because of this dependency 5 | ], function( jQuery ) { 6 | 7 | "use strict"; 8 | 9 | // Based off of the plugin by Clint Helfers, with permission. 10 | // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 11 | jQuery.fn.delay = function( time, type ) { 12 | time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 13 | type = type || "fx"; 14 | 15 | return this.queue( type, function( next, hooks ) { 16 | var timeout = window.setTimeout( next, time ); 17 | hooks.stop = function() { 18 | window.clearTimeout( timeout ); 19 | }; 20 | } ); 21 | }; 22 | 23 | return jQuery.fn.delay; 24 | } ); 25 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/exports/global.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core" 3 | ], function( jQuery, noGlobal ) { 4 | 5 | "use strict"; 6 | 7 | var 8 | 9 | // Map over jQuery in case of overwrite 10 | _jQuery = window.jQuery, 11 | 12 | // Map over the $ in case of overwrite 13 | _$ = window.$; 14 | 15 | jQuery.noConflict = function( deep ) { 16 | if ( window.$ === jQuery ) { 17 | window.$ = _$; 18 | } 19 | 20 | if ( deep && window.jQuery === jQuery ) { 21 | window.jQuery = _jQuery; 22 | } 23 | 24 | return jQuery; 25 | }; 26 | 27 | // Expose jQuery and $ identifiers, even in AMD 28 | // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 29 | // and CommonJS for browser emulators (#13566) 30 | if ( !noGlobal ) { 31 | window.jQuery = window.$ = jQuery; 32 | } 33 | 34 | } ); 35 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/event/alias.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | 4 | "../event", 5 | "./trigger" 6 | ], function( jQuery ) { 7 | 8 | "use strict"; 9 | 10 | jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + 11 | "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 12 | "change select submit keydown keypress keyup contextmenu" ).split( " " ), 13 | function( i, name ) { 14 | 15 | // Handle event binding 16 | jQuery.fn[ name ] = function( data, fn ) { 17 | return arguments.length > 0 ? 18 | this.on( name, null, data, fn ) : 19 | this.trigger( name ); 20 | }; 21 | } ); 22 | 23 | jQuery.fn.extend( { 24 | hover: function( fnOver, fnOut ) { 25 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 26 | } 27 | } ); 28 | 29 | } ); 30 | -------------------------------------------------------------------------------- /2. npm/2-2. 包配置/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "description": "useless, just test, will not publish to npm", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/DuYi-Edu/DuYi-PackageManager.git" 12 | }, 13 | "author": "yuanjin", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/DuYi-Edu/DuYi-PackageManager/issues" 17 | }, 18 | "homepage": "https://github.com/DuYi-Edu/DuYi-PackageManager#readme", 19 | "dependencies": { 20 | "jquery": "^3.4.1", 21 | "lodash": "^4.17.15" 22 | }, 23 | "devDependencies": { 24 | "mocha": "^6.2.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/jquery.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./selector", 4 | "./traversing", 5 | "./callbacks", 6 | "./deferred", 7 | "./deferred/exceptionHook", 8 | "./core/ready", 9 | "./data", 10 | "./queue", 11 | "./queue/delay", 12 | "./attributes", 13 | "./event", 14 | "./event/focusin", 15 | "./manipulation", 16 | "./manipulation/_evalUrl", 17 | "./wrap", 18 | "./css", 19 | "./css/hiddenVisibleSelectors", 20 | "./serialize", 21 | "./ajax", 22 | "./ajax/xhr", 23 | "./ajax/script", 24 | "./ajax/jsonp", 25 | "./ajax/load", 26 | "./event/ajax", 27 | "./effects", 28 | "./effects/animatedSelector", 29 | "./offset", 30 | "./dimensions", 31 | "./deprecated", 32 | "./exports/amd", 33 | "./exports/global" 34 | ], function( jQuery ) { 35 | 36 | "use strict"; 37 | 38 | return jQuery; 39 | 40 | } ); 41 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/getAll.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/nodeName" 4 | ], function( jQuery, nodeName ) { 5 | 6 | "use strict"; 7 | 8 | function getAll( context, tag ) { 9 | 10 | // Support: IE <=9 - 11 only 11 | // Use typeof to avoid zero-argument method invocation on host objects (#15151) 12 | var ret; 13 | 14 | if ( typeof context.getElementsByTagName !== "undefined" ) { 15 | ret = context.getElementsByTagName( tag || "*" ); 16 | 17 | } else if ( typeof context.querySelectorAll !== "undefined" ) { 18 | ret = context.querySelectorAll( tag || "*" ); 19 | 20 | } else { 21 | ret = []; 22 | } 23 | 24 | if ( tag === undefined || tag && nodeName( context, tag ) ) { 25 | return jQuery.merge( [ context ], ret ); 26 | } 27 | 28 | return ret; 29 | } 30 | 31 | return getAll; 32 | } ); 33 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/_evalUrl.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../ajax" 3 | ], function( jQuery ) { 4 | 5 | "use strict"; 6 | 7 | jQuery._evalUrl = function( url, options ) { 8 | return jQuery.ajax( { 9 | url: url, 10 | 11 | // Make this explicit, since user can override this through ajaxSetup (#11264) 12 | type: "GET", 13 | dataType: "script", 14 | cache: true, 15 | async: false, 16 | global: false, 17 | 18 | // Only evaluate the response if it is successful (gh-4126) 19 | // dataFilter is not invoked for failure responses, so using it instead 20 | // of the default converter is kludgy but it works. 21 | converters: { 22 | "text script": function() {} 23 | }, 24 | dataFilter: function( response ) { 25 | jQuery.globalEval( response, options ); 26 | } 27 | } ); 28 | }; 29 | 30 | return jQuery._evalUrl; 31 | 32 | } ); 33 | -------------------------------------------------------------------------------- /3. yarn/3-3. yarn的特别礼物/笔记.md: -------------------------------------------------------------------------------- 1 | # yarn 的特别礼物 2 | 3 | 在终端命令上,yarn不仅仅是对npm的命令做了一个改名,还增加了一些原本没有的命令,这些命令在某些时候使用起来非常方便 4 | 5 | 1. **yarn check** 6 | 7 | 使用```yarn check```命令,可以验证package.json文件的依赖记录和lock文件是否一致 8 | 9 | 这对于防止篡改非常有用 10 | 11 | 2. **yarn audit** 12 | 13 | 使用```yarn audit```命令,可以检查本地安装的包有哪些已知漏洞,以表格的形式列出,漏洞级别分为以下几种: 14 | 15 | - INFO:信息级别 16 | - LOW: 低级别 17 | - MODERATE:中级别 18 | - HIGH:高级别 19 | - CRITICAL:关键级别 20 | 21 | 3. **yarn why** 22 | 23 | 使用```yarn why 包名```命令,可以在控制台打印出为什么安装了这个包,哪些包会用到它 24 | 25 | 4. **yarn create** 26 | 27 | 非常有趣的命令 28 | 29 | 今后,我们会学习一些脚手架,所谓脚手架,就是使用一个命令来搭建一个工程结构 30 | 31 | 过去,我们都是使用如下的做法: 32 | 33 | 1) 全局安装脚手架工具 34 | 2) 使用全局命令搭建脚手架 35 | 36 | 由于大部分脚手架工具都是以```create-xxx```的方式命名的,比如react的官方脚手架名称为```create-react-app``` 37 | 38 | 因此,可以使用```yarn create```命令来一步完成安装和搭建 39 | 40 | 例如: 41 | 42 | ```shell 43 | yarn create react-app my-app 44 | # 等同于下面的两条命令 45 | yarn global add create-react-app 46 | create-react-app my-app 47 | ``` 48 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/isAttached.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/documentElement", 4 | "../selector" // jQuery.contains 5 | ], function( jQuery, documentElement ) { 6 | "use strict"; 7 | 8 | var isAttached = function( elem ) { 9 | return jQuery.contains( elem.ownerDocument, elem ); 10 | }, 11 | composed = { composed: true }; 12 | 13 | // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only 14 | // Check attachment across shadow DOM boundaries when possible (gh-3504) 15 | // Support: iOS 10.0-10.2 only 16 | // Early iOS 10 versions support `attachShadow` but not `getRootNode`, 17 | // leading to errors. We need to check for `getRootNode`. 18 | if ( documentElement.getRootNode ) { 19 | isAttached = function( elem ) { 20 | return jQuery.contains( elem.ownerDocument, elem ) || 21 | elem.getRootNode( composed ) === elem.ownerDocument; 22 | }; 23 | } 24 | 25 | return isAttached; 26 | } ); 27 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/wrapMap.js: -------------------------------------------------------------------------------- 1 | define( function() { 2 | 3 | "use strict"; 4 | 5 | // We have to close these tags to support XHTML (#13200) 6 | var wrapMap = { 7 | 8 | // Support: IE <=9 only 9 | option: [ 1, "" ], 10 | 11 | // XHTML parsers do not magically insert elements in the 12 | // same way that tag soup parsers do. So we cannot shorten 13 | // this by omitting or other required elements. 14 | thead: [ 1, "", "
" ], 15 | col: [ 2, "", "
" ], 16 | tr: [ 2, "", "
" ], 17 | td: [ 3, "", "
" ], 18 | 19 | _default: [ 0, "", "" ] 20 | }; 21 | 22 | // Support: IE <=9 only 23 | wrapMap.optgroup = wrapMap.option; 24 | 25 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 26 | wrapMap.th = wrapMap.td; 27 | 28 | return wrapMap; 29 | } ); 30 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes/support.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/document", 3 | "../var/support" 4 | ], function( document, support ) { 5 | 6 | "use strict"; 7 | 8 | ( function() { 9 | var input = document.createElement( "input" ), 10 | select = document.createElement( "select" ), 11 | opt = select.appendChild( document.createElement( "option" ) ); 12 | 13 | input.type = "checkbox"; 14 | 15 | // Support: Android <=4.3 only 16 | // Default value for a checkbox should be "on" 17 | support.checkOn = input.value !== ""; 18 | 19 | // Support: IE <=11 only 20 | // Must access selectedIndex to make default options select 21 | support.optSelected = opt.selected; 22 | 23 | // Support: IE <=11 only 24 | // An input loses its value after becoming a radio 25 | input = document.createElement( "input" ); 26 | input.value = "t"; 27 | input.type = "radio"; 28 | support.radioValue = input.value === "t"; 29 | } )(); 30 | 31 | return support; 32 | 33 | } ); 34 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-3. pnpm/笔记.md: -------------------------------------------------------------------------------- 1 | # pnpm 2 | 3 | pnpm是一种新起的包管理器,从npm的下载量看,目前还没有超过yarn,但它的实现方式值得主流包管理器学习,某些开发者极力推荐使用pnpm 4 | 5 | 从结果上来看,它具有以下优势: 6 | 7 | 1. 目前,安装效率高于npm和yarn的最新版 8 | 2. 极其简洁的node_modules目录 9 | 3. 避免了开发时使用间接依赖的问题 10 | 4. 能极大的降低磁盘空间的占用 11 | 12 | ## 安装和使用 13 | 14 | 全局安装pnpm 15 | 16 | ```shell 17 | npm install -g pnpm 18 | ``` 19 | 20 | 之后在使用时,只需要把npm替换为pnpm即可 21 | 22 | 如果要执行安装在本地的CLI,可以使用pnpx,它和 npx 的功能完全一样,唯一不同的是,在使用pnpx执行一个需要安装的命令时,会使用pnpm进行安装 23 | 24 | > 比如```npx mocha```执行本地的```mocha```命令时,如果```mocha```没有安装,则npx会自动的、临时的安装mocha,安装好后,自动运行mocha命令 25 | 26 | ## pnpm原理 27 | 28 | 1. 同 yarn 和 npm 一样,pnpm 仍然使用缓存来保存已经安装过的包,以及使用 pnpm-lock.yaml 来记录详细的依赖版本 29 | 30 | 2. 不同于 yarn 和 npm, pnpm 使用**符号链接和硬链接**(可将它们想象成快捷方式)的做法来放置依赖,从而规避了从缓存中拷贝文件的时间,使得安装和卸载的速度更快 31 | 32 | 3. 由于使用了**符号链接和硬链接**,pnpm可以规避windows操作系统路径过长的问题,因此,它选择使用树形的依赖结果,有着几乎完美的依赖管理。也因为如此,项目中只能使用直接依赖,而不能使用间接依赖 33 | 34 | ## 注意事项 35 | 36 | 由于 pnpm 会改动 node_modules 目录结构,使得每个包只能使用直接依赖,而不能使用间接依赖,因此,如果使用 pnpm 安装的包中包含间接依赖,则会出现问题(**现在不会了,除非使用了绝对路径**) 37 | 38 | 由于 pnpm 超高的安装卸载效率,越来越多的包开始修正之前的间接依赖代码 39 | 40 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/finalPropName.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/document", 3 | "../core" 4 | ], function( document, jQuery ) { 5 | 6 | "use strict"; 7 | 8 | var cssPrefixes = [ "Webkit", "Moz", "ms" ], 9 | emptyStyle = document.createElement( "div" ).style, 10 | vendorProps = {}; 11 | 12 | // Return a vendor-prefixed property or undefined 13 | function vendorPropName( name ) { 14 | 15 | // Check for vendor prefixed names 16 | var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 17 | i = cssPrefixes.length; 18 | 19 | while ( i-- ) { 20 | name = cssPrefixes[ i ] + capName; 21 | if ( name in emptyStyle ) { 22 | return name; 23 | } 24 | } 25 | } 26 | 27 | // Return a potentially-mapped jQuery.cssProps or vendor prefixed property 28 | function finalPropName( name ) { 29 | var final = jQuery.cssProps[ name ] || vendorProps[ name ]; 30 | 31 | if ( final ) { 32 | return final; 33 | } 34 | if ( name in emptyStyle ) { 35 | return name; 36 | } 37 | return vendorProps[ name ] = vendorPropName( name ) || name; 38 | } 39 | 40 | return finalPropName; 41 | 42 | } ); 43 | -------------------------------------------------------------------------------- /2. npm/2-1. 包的安装/笔记.md: -------------------------------------------------------------------------------- 1 | # 包的安装 2 | 3 | > 安装(install)即下载包 4 | > 由于 npm 的官方 registry 服务器位于国外,可能受网速影响导致下载缓慢或失败。因此,安装好 npm 之后,需要重新设置 registry 的地址为国内地址。目前,淘宝 https://registry.npm.taobao.org 提供了国内的 registry 地址,先设置到该地址。设置方式为```npm config set registry https://registry.npm.taobao.org```。设置好后,通过命令```npm config get registry```进行检查 5 | > ![](assets/2019-12-16-10-25-13.png) 6 | 7 | npm 安装一个包,分为两种安装方式: 8 | 9 | 1. 本地安装 10 | 2. 全局安装 11 | 12 | 13 | ## 本地安装 14 | 15 | 使用命令```npm install 包名```或```npm i 包名```即可完成本地安装 16 | 17 | 本地安装的包出现在当前目录下的```node_modules```目录中 18 | 19 | > 随着开发的进展,```node_modules```目录会变得异常庞大,目录下的内容不适合直接传输到生产环境,因此通常使用```.gitignore```文件忽略该目录中的内容 20 | > 本地安装适用于绝大部分的包,它会在当前目录及其子目录中发挥作用 21 | > 通常在项目的根目录中使用本地安装 22 | > 安装一个包的时候,npm 会自动管理依赖,它会下载该包的依赖包到```node_modules```目录中 23 | > 如果本地安装的包带有 CLI,npm 会将它的 CLI 脚本文件放置到```node_modules/.bin```下,使用命令```npx 命令名```即可调用 24 | 25 | ## 全局安装 26 | 27 | 全局安装的包放置在一个特殊的全局目录,该目录可以通过命令```npm config get prefix```查看 28 | 29 | 使用命令```npm install --global 包名``` 或 ```npm i -g 包名``` 30 | 31 | 重要:**全局安装的包并非所有工程可用,它仅提供全局的 CLI 工具** 32 | 33 | 大部分情况下,都不需要全局安装包,除非: 34 | 35 | 1. 包的版本非常稳定,很少有大的更新 36 | 2. 提供的 CLI 工具在各个工程中使用的非常频繁 37 | 3. CLI 工具仅为开发环境提供支持,而非部署环境 -------------------------------------------------------------------------------- /2. npm/2-9. 发布包/test12345/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2050 bangbangji 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/exports/amd.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | "use strict"; 6 | 7 | // Register as a named AMD module, since jQuery can be concatenated with other 8 | // files that may use define, but not via a proper concatenation script that 9 | // understands anonymous AMD modules. A named AMD is safest and most robust 10 | // way to register. Lowercase jquery is used because AMD module names are 11 | // derived from file names, and jQuery is normally delivered in a lowercase 12 | // file name. Do this after creating the global so that if an AMD module wants 13 | // to call noConflict to hide this version of jQuery, it will work. 14 | 15 | // Note that for maximum portability, libraries that are not jQuery should 16 | // declare themselves as anonymous modules, and avoid setting a global if an 17 | // AMD loader is present. jQuery is a special case. For more information, see 18 | // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 19 | 20 | if ( typeof define === "function" && define.amd ) { 21 | define( "jquery", [], function() { 22 | return jQuery; 23 | } ); 24 | } 25 | 26 | } ); 27 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/getMovies.js: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const cheerio = require("cheerio"); 3 | /** 4 | * 得到所有电影的html字符串 5 | */ 6 | async function getMoviesHtml() { 7 | const resp = await axios.get("https://movie.douban.com/chart") 8 | return resp.data; 9 | } 10 | 11 | /** 12 | * 获取所有电影数据 13 | */ 14 | async function getMoviesData() { 15 | const html = await getMoviesHtml(); 16 | const $ = cheerio.load(html); 17 | var trs = $("tr.item") 18 | var movies = []; 19 | for (let i = 0; i < trs.length; i++) { 20 | var tr = trs[i]; 21 | //分析每个tr的数据,得到一部电影对象 22 | var m = getMovie($(tr)); 23 | movies.push(m); 24 | } 25 | return movies; 26 | } 27 | 28 | /** 29 | * 分析tr,得到一部电影对象 30 | * @param {*} tr 31 | */ 32 | function getMovie(tr) { 33 | var name = tr.find("div.pl2 a").text(); 34 | name = name.replace(/\s/g, "");//去掉空白字符 35 | name = name.split("/")[0]; 36 | 37 | var imgSrc = tr.find("a.nbg img").attr("src"); 38 | var detail = tr.find("div.pl2 p.pl").text(); 39 | return { 40 | name, 41 | imgSrc, 42 | detail 43 | } 44 | } 45 | 46 | module.exports = getMoviesData; -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /3. yarn/3-1. yarn简介/笔记.md: -------------------------------------------------------------------------------- 1 | # yarn 简介 2 | 3 | > yarn 官网:https://www.yarnpkg.com/zh-Hans/ 4 | 5 | yarn 是由Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具,**它仍然使用 npm 的registry**,不过提供了全新 CLI 来对包进行管理 6 | 7 | 过去,yarn 的出现极大的抢夺了 npm 的市场,甚至有人戏言,npm 只剩下一个 registry 了。 8 | 9 | 之所以会出现这种情况,是因为在过去,npm 存在下面的问题: 10 | 11 | - 依赖目录嵌套层次深:过去,npm 的依赖是嵌套的,这在 windows 系统上是一个极大的问题,由于众所周知的原因,windows 系统无法支持太深的目录 12 | - 下载速度慢 13 | - 由于嵌套层次的问题,所以npm对包的下载只能是串行的,即前一个包下载完后才会下载下一个包,导致带宽资源没有完全利用 14 | - 多个相同版本的包被重复的下载 15 | - 控制台输出繁杂:过去,npm 安装包的时候,每安装一个依赖,就会输出依赖的详细信息,导致一次安装有大量的信息输出到控制台,遇到错误极难查看 16 | - 工程移植问题:由于 npm 的版本依赖可以是模糊的,可能会导致工程移植后,依赖的确切版本不一致。 17 | 18 | 针对上述问题,yarn 从诞生那天就已经解决,它用到了以下的手段: 19 | 20 | - 使用扁平的目录结构 21 | - 并行下载 22 | - 使用本地缓存 23 | - 控制台仅输出关键信息 24 | - 使用yanr-lock文件记录确切依赖 25 | 26 | 不仅如此,yarn还优化了以下内容: 27 | 28 | - 增加了某些功能强大的命令 29 | - 让既有的命令更加语义化 30 | - 本地安装的CLI工具可以使用 yarn 直接启动 31 | - 将全局安装的目录当作一个普通的工程,生成package.json文件,便于全局安装移植 32 | 33 | yarn 的出现给 npm 带来了巨大的压力,很快,npm 学习了 yarn 先进的理念,不断的对自身进行优化,到了目前的npm6版本,几乎完全解决了上面的问题: 34 | 35 | - 目录扁平化 36 | - 并行下载 37 | - 本地缓存 38 | - 使用package-lock记录确切依赖 39 | - 增加了大量的命令别名 40 | - 内置了npx,可以启动本地的CLI工具 41 | - 极大的简化了控制台输出 42 | 43 | **总结** 44 | 45 | npm6 之后,可以说npm已经和yarn非常接近,甚至没有差距了。很多新的项目,又重新从yarn转回到npm。 46 | 47 | 这两个包管理器是目前的主流,都必须要学习。 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/support.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/document", 3 | "../var/support" 4 | ], function( document, support ) { 5 | 6 | "use strict"; 7 | 8 | ( function() { 9 | var fragment = document.createDocumentFragment(), 10 | div = fragment.appendChild( document.createElement( "div" ) ), 11 | input = document.createElement( "input" ); 12 | 13 | // Support: Android 4.0 - 4.3 only 14 | // Check state lost if the name is set (#11217) 15 | // Support: Windows Web Apps (WWA) 16 | // `name` and `type` must use .setAttribute for WWA (#14901) 17 | input.setAttribute( "type", "radio" ); 18 | input.setAttribute( "checked", "checked" ); 19 | input.setAttribute( "name", "t" ); 20 | 21 | div.appendChild( input ); 22 | 23 | // Support: Android <=4.1 only 24 | // Older WebKit doesn't clone checked state correctly in fragments 25 | support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 26 | 27 | // Support: IE <=11 only 28 | // Make sure textarea (and checkbox) defaultValue is properly cloned 29 | div.innerHTML = ""; 30 | support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 31 | } )(); 32 | 33 | return support; 34 | 35 | } ); 36 | -------------------------------------------------------------------------------- /2. npm/2-8. 其他npm命令/笔记.md: -------------------------------------------------------------------------------- 1 | # 其他npm命令 {ignore} 2 | 3 | [toc] 4 | 5 | ## 安装 6 | 7 | 1. 精确安装最新版本 8 | 9 | ```shell 10 | npm install --save-exact 包名 11 | npm install -E 包名 12 | ``` 13 | 14 | 2. 安装指定版本 15 | 16 | ```shell 17 | npm install 包名@版本号 18 | ``` 19 | 20 | ## 查询 21 | 22 | 1. 查询包安装路径 23 | 24 | ```shell 25 | npm root [-g] 26 | ``` 27 | 28 | 2. 查看包信息 29 | 30 | ```shell 31 | npm view 包名 [子信息] 32 | ## view aliases:v info show 33 | ``` 34 | 35 | 3. 查询安装包 36 | 37 | ```shell 38 | npm list [-g] [--depth=依赖深度] 39 | ## list aliases: ls la ll 40 | ``` 41 | 42 | ## 更新 43 | 44 | 1. 检查有哪些包需要更新 45 | 46 | ```shell 47 | npm outdated 48 | ``` 49 | 50 | 2. 更新包 51 | 52 | ```shell 53 | npm update [-g] [包名] 54 | ## update 别名(aliases):up、upgrade 55 | ``` 56 | 57 | ## 卸载包 58 | 59 | ```shell 60 | npm uninstall [-g] 包名 61 | ## uninstall aliases: remove, rm, r, un, unlink 62 | ``` 63 | 64 | ## npm 配置 65 | 66 | npm的配置会对其他命令产生或多或少的影响 67 | 68 | 安装好npm之后,最终会产生两个配置文件,一个是用户配置,一个是系统配置,当两个文件的配置项有冲突的时候,用户配置会覆盖系统配置 69 | 70 | 通常,我们不关心具体的配置文件,而只关心最终生效的配置 71 | 72 | 通过下面的命令可以查询目前生效的各种配置 73 | 74 | ```shell 75 | npm config ls [-l] [--json] 76 | ``` 77 | 78 | 另外,可以通过下面的命令操作配置 79 | 80 | 1. 获取某个配置项 81 | 82 | ```shell 83 | npm config get 配置项 84 | ``` 85 | 86 | 2. 设置某个配置项 87 | 88 | ```shell 89 | npm config set 配置项=值 90 | ``` 91 | 92 | 3. 移除某个配置项 93 | 94 | ```shell 95 | npm config delete 配置项 96 | ``` -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/DOMEval.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../var/document" 3 | ], function( document ) { 4 | "use strict"; 5 | 6 | var preservedScriptAttributes = { 7 | type: true, 8 | src: true, 9 | nonce: true, 10 | noModule: true 11 | }; 12 | 13 | function DOMEval( code, node, doc ) { 14 | doc = doc || document; 15 | 16 | var i, val, 17 | script = doc.createElement( "script" ); 18 | 19 | script.text = code; 20 | if ( node ) { 21 | for ( i in preservedScriptAttributes ) { 22 | 23 | // Support: Firefox 64+, Edge 18+ 24 | // Some browsers don't support the "nonce" property on scripts. 25 | // On the other hand, just using `getAttribute` is not enough as 26 | // the `nonce` attribute is reset to an empty string whenever it 27 | // becomes browsing-context connected. 28 | // See https://github.com/whatwg/html/issues/2369 29 | // See https://html.spec.whatwg.org/#nonce-attributes 30 | // The `node.getAttribute` check was added for the sake of 31 | // `jQuery.globalEval` so that it can fake a nonce-containing node 32 | // via an object. 33 | val = node[ i ] || node.getAttribute && node.getAttribute( i ); 34 | if ( val ) { 35 | script.setAttribute( i, val ); 36 | } 37 | } 38 | } 39 | doc.head.appendChild( script ).parentNode.removeChild( script ); 40 | } 41 | 42 | return DOMEval; 43 | } ); 44 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/var/isHiddenWithinTree.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../../core", 3 | "../../core/isAttached" 4 | 5 | // css is assumed 6 | ], function( jQuery, isAttached ) { 7 | "use strict"; 8 | 9 | // isHiddenWithinTree reports if an element has a non-"none" display style (inline and/or 10 | // through the CSS cascade), which is useful in deciding whether or not to make it visible. 11 | // It differs from the :hidden selector (jQuery.expr.pseudos.hidden) in two important ways: 12 | // * A hidden ancestor does not force an element to be classified as hidden. 13 | // * Being disconnected from the document does not force an element to be classified as hidden. 14 | // These differences improve the behavior of .toggle() et al. when applied to elements that are 15 | // detached or contained within hidden ancestors (gh-2404, gh-2863). 16 | return function( elem, el ) { 17 | 18 | // isHiddenWithinTree might be called from jQuery#filter function; 19 | // in that case, element will be second argument 20 | elem = el || elem; 21 | 22 | // Inline style trumps all 23 | return elem.style.display === "none" || 24 | elem.style.display === "" && 25 | 26 | // Otherwise, check computed style 27 | // Support: Firefox <=43 - 45 28 | // Disconnected elements can have computed display: none, so first confirm that elem is 29 | // in the document. 30 | isAttached( elem ) && 31 | 32 | jQuery.css( elem, "display" ) === "none"; 33 | }; 34 | } ); 35 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/access.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/toType", 4 | "../var/isFunction" 5 | ], function( jQuery, toType, isFunction ) { 6 | 7 | "use strict"; 8 | 9 | // Multifunctional method to get and set values of a collection 10 | // The value/s can optionally be executed if it's a function 11 | var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 12 | var i = 0, 13 | len = elems.length, 14 | bulk = key == null; 15 | 16 | // Sets many values 17 | if ( toType( key ) === "object" ) { 18 | chainable = true; 19 | for ( i in key ) { 20 | access( elems, fn, i, key[ i ], true, emptyGet, raw ); 21 | } 22 | 23 | // Sets one value 24 | } else if ( value !== undefined ) { 25 | chainable = true; 26 | 27 | if ( !isFunction( value ) ) { 28 | raw = true; 29 | } 30 | 31 | if ( bulk ) { 32 | 33 | // Bulk operations run against the entire set 34 | if ( raw ) { 35 | fn.call( elems, value ); 36 | fn = null; 37 | 38 | // ...except when executing function values 39 | } else { 40 | bulk = fn; 41 | fn = function( elem, key, value ) { 42 | return bulk.call( jQuery( elem ), value ); 43 | }; 44 | } 45 | } 46 | 47 | if ( fn ) { 48 | for ( ; i < len; i++ ) { 49 | fn( 50 | elems[ i ], key, raw ? 51 | value : 52 | value.call( elems[ i ], i, fn( elems[ i ], key ) ) 53 | ); 54 | } 55 | } 56 | } 57 | 58 | if ( chainable ) { 59 | return elems; 60 | } 61 | 62 | // Gets 63 | if ( bulk ) { 64 | return fn.call( elems ); 65 | } 66 | 67 | return len ? fn( elems[ 0 ], key ) : emptyGet; 68 | }; 69 | 70 | return access; 71 | 72 | } ); 73 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/event/focusin.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../data/var/dataPriv", 4 | "./support", 5 | 6 | "../event", 7 | "./trigger" 8 | ], function( jQuery, dataPriv, support ) { 9 | 10 | "use strict"; 11 | 12 | // Support: Firefox <=44 13 | // Firefox doesn't have focus(in | out) events 14 | // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 15 | // 16 | // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 17 | // focus(in | out) events fire after focus & blur events, 18 | // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 19 | // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 20 | if ( !support.focusin ) { 21 | jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 22 | 23 | // Attach a single capturing handler on the document while someone wants focusin/focusout 24 | var handler = function( event ) { 25 | jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 26 | }; 27 | 28 | jQuery.event.special[ fix ] = { 29 | setup: function() { 30 | var doc = this.ownerDocument || this, 31 | attaches = dataPriv.access( doc, fix ); 32 | 33 | if ( !attaches ) { 34 | doc.addEventListener( orig, handler, true ); 35 | } 36 | dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 37 | }, 38 | teardown: function() { 39 | var doc = this.ownerDocument || this, 40 | attaches = dataPriv.access( doc, fix ) - 1; 41 | 42 | if ( !attaches ) { 43 | doc.removeEventListener( orig, handler, true ); 44 | dataPriv.remove( doc, fix ); 45 | 46 | } else { 47 | dataPriv.access( doc, fix, attaches ); 48 | } 49 | } 50 | }; 51 | } ); 52 | } 53 | 54 | return jQuery; 55 | } ); 56 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/external/sizzle/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/sizzle 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /1. 概述/课件.md: -------------------------------------------------------------------------------- 1 | # 包管理工具概述 2 | 3 | > 本门课程的前置知识:JavaScript、ES6、模块化、git 4 | > 本门课程的所有代码均书写在 nodejs 环境中,不涉及浏览器环境 5 | 6 | ## 概念 7 | 8 | **模块(module)** 9 | 10 | 通常以单个文件形式存在的功能片段,入口文件通常称之为**入口模块**或**主模块** 11 | 12 | **库(library,简称lib)** 13 | 14 | 以一个或多个模块组成的完整功能块,为开发中某一方面的问题提供完整的解决方案 15 | 16 | **包(package)** 17 | 18 | 包含元数据的库,这些元数据包括:名称、描述、git主页、许可证协议、作者、依赖等等 19 | 20 | ![](assets/2019-12-13-10-39-18.png) 21 | 22 | ## 背景 23 | 24 | CommonJS 的出现,使 node 环境下的 JS 代码可以用模块更加细粒度的划分。一个类、一个函数、一个对象、一个配置等等均可以作为模块,这种细粒度的划分,是开发大型应用的基石。 25 | 26 | 为了解决在开发过程中遇到的常见问题,比如加密、提供常见的工具方法、模拟数据等等,一时间,在前端社区涌现了大量的第三方库。这些库使用 CommonJS 标准书写而成,非常容易使用。 27 | 28 | 然而,在下载使用这些第三方库的时候,遇到难以处理的问题: 29 | 30 | - **下载过程繁琐** 31 | - 进入官网或 github 主页 32 | - 找到并下载相应的版本 33 | - 拷贝到工程的目录中 34 | - 如果遇到有同名的库,需要更改名称 35 | - **如果该库需要依赖其他库,还需要按照要求先下载其他库** 36 | - **开发环境中安装的大量的库如何在生产环境中还原,又如何区分** 37 | - **更新一个库极度麻烦** 38 | - **自己开发的库,如何在下一次开发使用** 39 | 40 | **以上问题,就是包管理工具要解决的问题** 41 | 42 | ## 前端包管理器 43 | 44 | > 本门课程讲解的包管理器 45 | > npm:重点 46 | > yarn:次重点 47 | > 其他:了解 48 | 49 | 几乎可以这样认为,前端所有的包管理器都是基于 npm 的,目前,npm 即是一个包管理器,也是其他包管理的基石 50 | 51 | npm 全称为 node package manager,即 node 包管理器,它运行在 node 环境中,让开发者可以用简单的方式完成包的查找、安装、更新、卸载、上传等操作 52 | 53 | > npm 之所以要运行在 node 环境,而不是浏览器环境,根本原因是因为浏览器环境无法提供下载、删除、读取本地文件的功能。而 node 属于服务器环境,没有浏览器的种种限制,理论上可以完全掌控运行 node 的计算机。 54 | 55 | npm 的出现,弥补了 node 没有包管理器的缺陷,于是很快,node 在安装文件中内置了 npm,当开发者安装好 node 之后,就自动安装了 npm,不仅如此,node 环境还专门为 npm 提供了良好的支持,使用 npm 下载的包更加方便了。 56 | 57 | npm 由三部分组成: 58 | 59 | - registry:入口 60 | - 可以把它想象成一个庞大的数据库 61 | - 第三方库的开发者,将自己的库按照 npm 的规范,打包上传到数据库中 62 | - 使用者通过统一的地址下载第三方包 63 | - 官网:https://www.npmjs.com/ 64 | - 查询包 65 | - 注册、登录、管理个人信息 66 | - CLI:command-line interface 命令行接口 67 | - 这一部分是本门课讲解的重点 68 | - 安装好 npm 后,通过 CLI 来使用 npm 的各种功能 69 | 70 | > node 和 npm 是互相成就的,node 的出现让 npm 火了,npm 的火爆带动了大量的第三方库的发展,很多优秀的第三方库打包上传到了 npm,这些第三方库又为 node 带来了大量的用户 -------------------------------------------------------------------------------- /2. npm/2-2. 包配置/笔记.md: -------------------------------------------------------------------------------- 1 | # 包配置 2 | 3 | 目前遇到的问题: 4 | 5 | 1. 拷贝工程后如何还原? 6 | 2. 如何区分开发依赖和生产依赖? 7 | 3. 如果自身的项目也是一个包,如何描述包的信息 8 | 9 | 以上这些问题都需要通过包的**配置文件**解决 10 | 11 | ## 配置文件 12 | 13 | npm 将每个使用 npm 的工程本身都看作是一个包,包的信息需要通过一个名称固定的配置文件来描述 14 | 15 | **配置文件的名称固定为:package.json** 16 | 17 | 可以手动创建该文件,而更多的时候,是通过命令```npm init```创建的 18 | 19 | 配置文件中可以描述大量的信息,包括: 20 | 21 | - name:包的名称,该名称必须是**英文单词字符**,支持连接符 22 | - version:版本 23 | - 版本规范:主版本号.次版本号.补丁版本号 24 | - 主版本号:仅当程序发生了重大变化时才会增长,如新增了重要功能、新增了大量的API、技术架构发生了重大变化 25 | - 次版本号:仅当程序发生了一些小变化时才会增长,如新增了一些小功能、新增了一些辅助型的API 26 | - 补丁版本号:仅当解决了一些 bug 或 进行了一些局部优化时更新,如修复了某个函数的 bug、提升了某个函数的运行效率 27 | - description:包的描述 28 | - homepage:官网地址 29 | - author:包的作者,必须是有效的 npm 账户名,书写规范是 ```account ```,例如:```zhangsan ```,不正确的账号和邮箱可能导致发布包时失败 30 | - repository:包的仓储地址,通常指 git 或 svn 的地址,它是一个对象 31 | - type:仓储类型,git 或 svn 32 | - url:地址 33 | - main:包的入口文件,使用包的人默认从该入口文件导入包的内容 34 | - keywords: 搜索关键字,发布包后,可以通过该数组中的关键字搜索到包 35 | 36 | 使用```npm init --yes```或```npm init -y```可以在生成配置文件时自动填充默认配置 37 | 38 | ## 保存依赖关系 39 | 40 | 大部分时候,我们仅仅是开发项目,并不会把它打包发布出去,尽管如此,我们仍然需要package.json文件 41 | 42 | **package.json文件最重要的作用,是记录当前工程的依赖** 43 | 44 | - dependencies:生产环境的依赖包 45 | - devDependencies:仅开发环境的依赖包 46 | 47 | 配置好依赖后,使用下面的命令即可安装依赖 48 | 49 | ```shell 50 | ## 本地安装所有依赖 dependencies + devDependencies 51 | npm install 52 | npm i 53 | 54 | ## 仅安装生产环境的依赖 dependencies 55 | npm install --production 56 | ``` 57 | 58 | 这样一来,代码移植就不是问题了,只需要移植源代码和package.json文件,不用移植node_modules目录,然后在移植之后通过命令即可重新恢复安装 59 | 60 | 为了更加方便的添加依赖,npm支持在使用install命令时,加入一些额外的参数,用于将安装的依赖包保存到package.json文件中 61 | 62 | 涉及的命令如下 63 | 64 | ```shell 65 | ## 安装依赖到生产环境 66 | npm i 包名 67 | npm i --save 包名 68 | npm i -S 包名 69 | 70 | ## 安装依赖到开发环境 71 | npm i --save-dev 包名 72 | npm i -D 包名 73 | ``` 74 | 75 | > 自动保存的依赖版本,例如```^15.1.3```,这种书写方式叫做语义版本号(semver version),具体规则后续讲解 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/wrap.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./var/isFunction", 4 | "./core/init", 5 | "./manipulation", // clone 6 | "./traversing" // parent, contents 7 | ], function( jQuery, isFunction ) { 8 | 9 | "use strict"; 10 | 11 | jQuery.fn.extend( { 12 | wrapAll: function( html ) { 13 | var wrap; 14 | 15 | if ( this[ 0 ] ) { 16 | if ( isFunction( html ) ) { 17 | html = html.call( this[ 0 ] ); 18 | } 19 | 20 | // The elements to wrap the target around 21 | wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 22 | 23 | if ( this[ 0 ].parentNode ) { 24 | wrap.insertBefore( this[ 0 ] ); 25 | } 26 | 27 | wrap.map( function() { 28 | var elem = this; 29 | 30 | while ( elem.firstElementChild ) { 31 | elem = elem.firstElementChild; 32 | } 33 | 34 | return elem; 35 | } ).append( this ); 36 | } 37 | 38 | return this; 39 | }, 40 | 41 | wrapInner: function( html ) { 42 | if ( isFunction( html ) ) { 43 | return this.each( function( i ) { 44 | jQuery( this ).wrapInner( html.call( this, i ) ); 45 | } ); 46 | } 47 | 48 | return this.each( function() { 49 | var self = jQuery( this ), 50 | contents = self.contents(); 51 | 52 | if ( contents.length ) { 53 | contents.wrapAll( html ); 54 | 55 | } else { 56 | self.append( html ); 57 | } 58 | } ); 59 | }, 60 | 61 | wrap: function( html ) { 62 | var htmlIsFunction = isFunction( html ); 63 | 64 | return this.each( function( i ) { 65 | jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 66 | } ); 67 | }, 68 | 69 | unwrap: function( selector ) { 70 | this.parent( selector ).not( "body" ).each( function() { 71 | jQuery( this ).replaceWith( this.childNodes ); 72 | } ); 73 | return this; 74 | } 75 | } ); 76 | 77 | return jQuery; 78 | } ); 79 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/parseHTML.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "./var/rsingleTag", 5 | "../manipulation/buildFragment", 6 | 7 | // This is the only module that needs core/support 8 | "./support" 9 | ], function( jQuery, document, rsingleTag, buildFragment, support ) { 10 | 11 | "use strict"; 12 | 13 | // Argument "data" should be string of html 14 | // context (optional): If specified, the fragment will be created in this context, 15 | // defaults to document 16 | // keepScripts (optional): If true, will include scripts passed in the html string 17 | jQuery.parseHTML = function( data, context, keepScripts ) { 18 | if ( typeof data !== "string" ) { 19 | return []; 20 | } 21 | if ( typeof context === "boolean" ) { 22 | keepScripts = context; 23 | context = false; 24 | } 25 | 26 | var base, parsed, scripts; 27 | 28 | if ( !context ) { 29 | 30 | // Stop scripts or inline event handlers from being executed immediately 31 | // by using document.implementation 32 | if ( support.createHTMLDocument ) { 33 | context = document.implementation.createHTMLDocument( "" ); 34 | 35 | // Set the base href for the created document 36 | // so any parsed elements with URLs 37 | // are based on the document's URL (gh-2965) 38 | base = context.createElement( "base" ); 39 | base.href = document.location.href; 40 | context.head.appendChild( base ); 41 | } else { 42 | context = document; 43 | } 44 | } 45 | 46 | parsed = rsingleTag.exec( data ); 47 | scripts = !keepScripts && []; 48 | 49 | // Single tag 50 | if ( parsed ) { 51 | return [ context.createElement( parsed[ 1 ] ) ]; 52 | } 53 | 54 | parsed = buildFragment( [ data ], context, scripts ); 55 | 56 | if ( scripts && scripts.length ) { 57 | jQuery( scripts ).remove(); 58 | } 59 | 60 | return jQuery.merge( [], parsed.childNodes ); 61 | }; 62 | 63 | return jQuery.parseHTML; 64 | 65 | } ); 66 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/curCSS.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/isAttached", 4 | "./var/rboxStyle", 5 | "./var/rnumnonpx", 6 | "./var/getStyles", 7 | "./support" 8 | ], function( jQuery, isAttached, rboxStyle, rnumnonpx, getStyles, support ) { 9 | 10 | "use strict"; 11 | 12 | function curCSS( elem, name, computed ) { 13 | var width, minWidth, maxWidth, ret, 14 | 15 | // Support: Firefox 51+ 16 | // Retrieving style before computed somehow 17 | // fixes an issue with getting wrong values 18 | // on detached elements 19 | style = elem.style; 20 | 21 | computed = computed || getStyles( elem ); 22 | 23 | // getPropertyValue is needed for: 24 | // .css('filter') (IE 9 only, #12537) 25 | // .css('--customProperty) (#3144) 26 | if ( computed ) { 27 | ret = computed.getPropertyValue( name ) || computed[ name ]; 28 | 29 | if ( ret === "" && !isAttached( elem ) ) { 30 | ret = jQuery.style( elem, name ); 31 | } 32 | 33 | // A tribute to the "awesome hack by Dean Edwards" 34 | // Android Browser returns percentage for some values, 35 | // but width seems to be reliably pixels. 36 | // This is against the CSSOM draft spec: 37 | // https://drafts.csswg.org/cssom/#resolved-values 38 | if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 39 | 40 | // Remember the original values 41 | width = style.width; 42 | minWidth = style.minWidth; 43 | maxWidth = style.maxWidth; 44 | 45 | // Put in the new values to get a computed value out 46 | style.minWidth = style.maxWidth = style.width = ret; 47 | ret = computed.width; 48 | 49 | // Revert the changed values 50 | style.width = width; 51 | style.minWidth = minWidth; 52 | style.maxWidth = maxWidth; 53 | } 54 | } 55 | 56 | return ret !== undefined ? 57 | 58 | // Support: IE <=9 - 11 only 59 | // IE returns zIndex value as an integer. 60 | ret + "" : 61 | ret; 62 | } 63 | 64 | return curCSS; 65 | } ); 66 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/script.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "../ajax" 5 | ], function( jQuery, document ) { 6 | 7 | "use strict"; 8 | 9 | // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 10 | jQuery.ajaxPrefilter( function( s ) { 11 | if ( s.crossDomain ) { 12 | s.contents.script = false; 13 | } 14 | } ); 15 | 16 | // Install script dataType 17 | jQuery.ajaxSetup( { 18 | accepts: { 19 | script: "text/javascript, application/javascript, " + 20 | "application/ecmascript, application/x-ecmascript" 21 | }, 22 | contents: { 23 | script: /\b(?:java|ecma)script\b/ 24 | }, 25 | converters: { 26 | "text script": function( text ) { 27 | jQuery.globalEval( text ); 28 | return text; 29 | } 30 | } 31 | } ); 32 | 33 | // Handle cache's special case and crossDomain 34 | jQuery.ajaxPrefilter( "script", function( s ) { 35 | if ( s.cache === undefined ) { 36 | s.cache = false; 37 | } 38 | if ( s.crossDomain ) { 39 | s.type = "GET"; 40 | } 41 | } ); 42 | 43 | // Bind script tag hack transport 44 | jQuery.ajaxTransport( "script", function( s ) { 45 | 46 | // This transport only deals with cross domain or forced-by-attrs requests 47 | if ( s.crossDomain || s.scriptAttrs ) { 48 | var script, callback; 49 | return { 50 | send: function( _, complete ) { 51 | script = jQuery( " 20 | ``` 21 | 22 | #### Babel 23 | 24 | [Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively. 25 | 26 | ```js 27 | import $ from "jquery"; 28 | ``` 29 | 30 | #### Browserify/Webpack 31 | 32 | There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this... 33 | 34 | ```js 35 | var $ = require("jquery"); 36 | ``` 37 | 38 | #### AMD (Asynchronous Module Definition) 39 | 40 | AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html). 41 | 42 | ```js 43 | define(["jquery"], function($) { 44 | 45 | }); 46 | ``` 47 | 48 | ### Node 49 | 50 | To include jQuery in [Node](nodejs.org), first install with npm. 51 | 52 | ```sh 53 | npm install jquery 54 | ``` 55 | 56 | For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes. 57 | 58 | ```js 59 | require("jsdom").env("", function(err, window) { 60 | if (err) { 61 | console.error(err); 62 | return; 63 | } 64 | 65 | var $ = require("jquery")(window); 66 | }); 67 | ``` 68 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/ready.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "../core/readyException", 5 | "../deferred" 6 | ], function( jQuery, document ) { 7 | 8 | "use strict"; 9 | 10 | // The deferred used on DOM ready 11 | var readyList = jQuery.Deferred(); 12 | 13 | jQuery.fn.ready = function( fn ) { 14 | 15 | readyList 16 | .then( fn ) 17 | 18 | // Wrap jQuery.readyException in a function so that the lookup 19 | // happens at the time of error handling instead of callback 20 | // registration. 21 | .catch( function( error ) { 22 | jQuery.readyException( error ); 23 | } ); 24 | 25 | return this; 26 | }; 27 | 28 | jQuery.extend( { 29 | 30 | // Is the DOM ready to be used? Set to true once it occurs. 31 | isReady: false, 32 | 33 | // A counter to track how many items to wait for before 34 | // the ready event fires. See #6781 35 | readyWait: 1, 36 | 37 | // Handle when the DOM is ready 38 | ready: function( wait ) { 39 | 40 | // Abort if there are pending holds or we're already ready 41 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 42 | return; 43 | } 44 | 45 | // Remember that the DOM is ready 46 | jQuery.isReady = true; 47 | 48 | // If a normal DOM Ready event fired, decrement, and wait if need be 49 | if ( wait !== true && --jQuery.readyWait > 0 ) { 50 | return; 51 | } 52 | 53 | // If there are functions bound, to execute 54 | readyList.resolveWith( document, [ jQuery ] ); 55 | } 56 | } ); 57 | 58 | jQuery.ready.then = readyList.then; 59 | 60 | // The ready event handler and self cleanup method 61 | function completed() { 62 | document.removeEventListener( "DOMContentLoaded", completed ); 63 | window.removeEventListener( "load", completed ); 64 | jQuery.ready(); 65 | } 66 | 67 | // Catch cases where $(document).ready() is called 68 | // after the browser event has already occurred. 69 | // Support: IE <=9 - 10 only 70 | // Older IE sometimes signals "interactive" too soon 71 | if ( document.readyState === "complete" || 72 | ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 73 | 74 | // Handle it asynchronously to allow scripts the opportunity to delay ready 75 | window.setTimeout( jQuery.ready ); 76 | 77 | } else { 78 | 79 | // Use the handy event callback 80 | document.addEventListener( "DOMContentLoaded", completed ); 81 | 82 | // A fallback to window.onload, that will always work 83 | window.addEventListener( "load", completed ); 84 | } 85 | 86 | } ); 87 | -------------------------------------------------------------------------------- /2. npm/2-5. 语义版本/笔记.md: -------------------------------------------------------------------------------- 1 | # 语义版本 2 | 3 | 思考:如果你编写了一个包A,依赖另外一个包B,你在编写代码时,包B的版本是2.4.1,你是希望使用你包的人一定要安装包B,并且是2.4.1版本,还是希望他可以安装更高的版本,如果你希望它安装更高的版本,高的什么程度呢? 4 | 5 | 回顾:版本号规则 6 | 7 | 版本规范:主版本号.次版本号.补丁版本号 8 | - 主版本号:仅当程序发生了重大变化时才会增长,如新增了重要功能、新增了大量的API、技术架构发生了重大变化 9 | - 次版本号:仅当程序发生了一些小变化时才会增长,如新增了一些小功能、新增了一些辅助型的API 10 | - 补丁版本号:仅当解决了一些 bug 或 进行了一些局部优化时更新,如修复了某个函数的 bug、提升了某个函数的运行效率 11 | 12 | 有的时候,我们希望:安装我的依赖包的时候,次版本号和补丁版本号是可以有提升的,但是主版本号不能变化 13 | 14 | 有的时候,我们又希望:安装我的依赖包的时候,只有补丁版本号可以提升,其他都不能提升 15 | 16 | 甚至我们希望依赖包保持固定的版本,尽管这比较少见 17 | 18 | 这样一来,就需要在配置文件中描述清楚具体的依赖规则,而不是直接写上版本号那么简单。 19 | 20 | 这种规则的描述,即**语义版本** 21 | 22 | 语义版本的书写规则非常丰富,下面列出了一些常见的书写方式 23 | 24 | | 符号 | 描述 | 示例 | 示例描述 | 25 | | :---: | :------------------: | :-----------: | :-------------------------------------------------------------: | 26 | | > | 大于某个版本 | >1.2.1 | 大于1.2.1版本 | 27 | | >= | 大于等于某个版本 | >=1.2.1 | 大于等于1.2.1版本 | 28 | | < | 小于某个版本 | <1.2.1 | 小于1.2.1版本 | 29 | | <= | 小于等于某个版本 | <=1.2.1 | 小于等于1.2.1版本 | 30 | | - | 介于两个版本之间 | 1.2.1 - 1.4.5 | 介于1.2.1和1.4.5之间 | 31 | | x | 不固定的版本号 | 1.3.x | 只要保证主版本号是1,次版本号是3即可 | 32 | | ~ | 补丁版本号可增 | ~1.3.4 | 保证主版本号是1,次版本号是3,补丁版本号大于等于4 | 33 | | ^ | 此版本和补丁版本可增 | ^1.3.4 | 保证主版本号是1,次版本号可以大于等于3,补丁版本号可以大于等于4 | 34 | | * | 最新版本 | * | 始终安装最新版本 | 35 | 36 | ## 避免还原的差异 37 | 38 | 版本依赖控制始终是一个两难的问题 39 | 40 | 如果允许版本增加,可以让依赖包的bug得以修复(补丁版本号),可以带来一些意外的惊喜(次版本号),但同样可能带来不确定的风险(新的bug) 41 | 42 | 如果不允许版本增加,可以获得最好的稳定性,但失去了依赖包自我优化的能力 43 | 44 | 而有的时候情况更加复杂,如果依赖包升级后,依赖也发生了变化,会有更多不确定的情况出现 45 | 46 | 基于此,npm 在安装包的时候,会自动生成一个 package-lock.json 文件,该文件记录了安装包时的确切依赖关系 47 | 48 | 当移植工程时,如果移植了 package-lock.json 文件,恢复安装时,会按照 package-lock.json 文件中的确切依赖进行安装,最大限度的避免了差异 49 | 50 | ## [扩展]npm的差异版本处理 51 | 52 | 如果两个包依赖同一个包的不同版本,如下图 53 | 54 | ![](assets/2019-12-17-15-17-47.png) 55 | 56 | 面对这种情况,在 node_modules 目录中,不会使用扁平的目录结构,而会形成嵌套的目录,如下图: 57 | 58 | ``` 59 | ├── node_modules 60 | │ ├── a 61 | │ │ ├── node_modules 62 | │ │ │ ├── c 63 | │ │ │ | |—— c包的文件 64 | │ │ │── a包的文件 65 | │ ├── b 66 | │ │ ├── node_modules 67 | │ │ │ ├── c 68 | │ │ │ | |—— c包的文件 69 | │ │ │── b包的文件 70 | ``` -------------------------------------------------------------------------------- /4. 其他包管理器/4-4. [扩展]pnpm原理/笔记.md: -------------------------------------------------------------------------------- 1 | # pnpm 原理 2 | 3 | ## 概念 4 | 5 | > 要彻底理解pnpm是怎么做的,需要有一些操作系统知识 6 | 7 | 1. **文件的本质** 8 | 9 | 在操作系统中,文件实际上是一个指针,只不过它指向的不是内存地址,而是一个外部存储地址(这里的外部存储可以是硬盘、U盘、甚至是网络) 10 | 11 | ![](assets/2019-12-31-16-29-21.png) 12 | 13 | 当我们删除文件时,删除的实际上是指针,因此,无论删除多么大的文件,速度都非常快。 14 | 15 | ![](assets/2019-12-31-16-29-43.png) 16 | 17 | 2. **文件的拷贝** 18 | 19 | 如果你复制一个文件,是将该文件指针指向的内容进行复制,然后产生一个新文件指向新的内容 20 | 21 | ![](assets/2019-12-31-16-30-25.png) 22 | 23 | 3. **硬链接 hard link** 24 | 25 | 硬链接的概念来自于 Unix 操作系统,它是指将一个文件A指针复制到另一个文件B指针中,文件B就是文件A的硬链接 26 | 27 | ![](assets/2019-12-31-16-33-59.png) 28 | 29 | 通过硬链接,不会产生额外的磁盘占用,并且,两个文件都能找到相同的磁盘内容 30 | 31 | 硬链接的数量没有限制,可以为同一个文件产生多个硬链接 32 | 33 | windows Vista操作系统开始,支持了创建硬链接的操作,在cmd中使用下面的命令可以创建硬链接 34 | 35 | ```shell 36 | mklink /h 链接名称 目标文件 37 | ``` 38 | 39 | 由于文件夹(目录)不存在文件内容,所以文件夹(目录)不能创建硬链接 40 | 41 | > 由于种种原因,在windows操作系统中,通常不要跨越盘符创建硬链接 42 | 43 | 4. **符号链接 symbol link** 44 | 45 | 符号链接又称为软连接,如果为某个文件或文件夹A创建符号连接B,则B指向A。 46 | 47 | ![](assets/2019-12-31-16-46-57.png) 48 | 49 | windows Vista操作系统开始,支持了创建符号链接的操作,在cmd中使用下面的命令可以创建符号链接: 50 | 51 | ```shell 52 | mklink /d 链接名称 目标文件 53 | # /d表示创建的是目录的符号链接,不写则是文件的符号链接 54 | ``` 55 | 56 | > 早期的windows系统不支持符号链接,但它提供了一个工具junction来达到类似的功能 57 | 58 | **符号链接和硬链接的区别** 59 | 60 | 1) 硬链接仅能链接文件,而符号链接可以链接目录 61 | 2) 硬链接在链接完成后仅和文件内容关联,和之前链接的文件没有任何关系。而符号链接始终和之前链接的文件关联,和文件内容不直接相关 62 | 63 | 5. **快捷方式** 64 | 65 | 快捷方式类似于符号链接,是windows系统早期就支持的链接方式。 66 | 67 | 它不仅仅是一个指向其他文件或目录的指针,其中还包含了各种信息:如权限、兼容性启动方式等其他各种属性 68 | 69 | 由于快捷方式是windows系统独有的,在跨平台的应用中一般不会使用 70 | 71 | 6. **node环境对硬链接和符号链接的处理** 72 | 73 | **硬链接**:硬链接是一个实实在在的文件,node不对其做任何特殊处理,也无法区别对待,实际上,node根本无从知晓该文件是不是一个硬链接 74 | 75 | **符号链接**:由于符号链接指向的是另一个文件或目录,当node执行符号链接下的JS文件时,会使用原始路径。 76 | 77 | ## pnpm原理 78 | 79 | pnpm使用符号链接和硬链接来构建node_modules目录 80 | 81 | 下面用一个例子来说明它的构建方式 82 | 83 | 假设两个包a和b,a依赖b: 84 | 85 | ![](assets/2019-12-31-17-50-59.png) 86 | 87 | 假设我们的工程为proj,直接依赖a,则安装时,pnpm会做下面的处理 88 | 89 | 1. 查询依赖关系,得到最终要安装的包:a和b 90 | 2. 查看a和b是否已经有缓存,如果没有,下载到缓存中,如果有,则进入下一步 91 | 3. 创建 node_modules 目录,并对目录进行结构初始化 92 | 93 | ![](assets/2019-12-31-18-09-53.png) 94 | 95 | 4. 从缓存的对应包中使用硬链接放置文件到相应包代码目录中 96 | 97 | ![](assets/2019-12-31-18-14-31.png) 98 | 99 | 5. 使用符号链接,将每个包的**直接依赖**放置到自己的目录中 100 | 101 | ![](assets/2019-12-31-18-19-48.png) 102 | 103 | 这样做的目的,是为了保证a的代码在执行过程中,可以读取到它们的直接依赖 104 | 105 | 6. 新版本的pnpm为了解决一些书写不规范的包(读取间接依赖)的问题,又将所有的工程非直接依赖,使用符号链接加入到了 .pnpm/node_modules 中 106 | 107 | 在本例中好像没有必要,但是如果b依赖c,a又要直接用c,这种不规范的用法现在pnpm通过这种方式支持了。 108 | 109 | > 但对于那些使用绝对路径的奇葩写法,可能永远也无法支持 110 | 111 | 7. 在工程的node_modules目录中使用符号链接,放置直接依赖 112 | 113 | ![](assets/2019-12-31-18-27-19.png) 114 | 115 | 8. 完成 -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/ready-no-deferred.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "../var/isFunction" 5 | ], function( jQuery, document, isFunction ) { 6 | 7 | "use strict"; 8 | 9 | var readyCallbacks = [], 10 | whenReady = function( fn ) { 11 | readyCallbacks.push( fn ); 12 | }, 13 | executeReady = function( fn ) { 14 | 15 | // Prevent errors from freezing future callback execution (gh-1823) 16 | // Not backwards-compatible as this does not execute sync 17 | window.setTimeout( function() { 18 | fn.call( document, jQuery ); 19 | } ); 20 | }; 21 | 22 | jQuery.fn.ready = function( fn ) { 23 | whenReady( fn ); 24 | return this; 25 | }; 26 | 27 | jQuery.extend( { 28 | 29 | // Is the DOM ready to be used? Set to true once it occurs. 30 | isReady: false, 31 | 32 | // A counter to track how many items to wait for before 33 | // the ready event fires. See #6781 34 | readyWait: 1, 35 | 36 | ready: function( wait ) { 37 | 38 | // Abort if there are pending holds or we're already ready 39 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 40 | return; 41 | } 42 | 43 | // Remember that the DOM is ready 44 | jQuery.isReady = true; 45 | 46 | // If a normal DOM Ready event fired, decrement, and wait if need be 47 | if ( wait !== true && --jQuery.readyWait > 0 ) { 48 | return; 49 | } 50 | 51 | whenReady = function( fn ) { 52 | readyCallbacks.push( fn ); 53 | 54 | while ( readyCallbacks.length ) { 55 | fn = readyCallbacks.shift(); 56 | if ( isFunction( fn ) ) { 57 | executeReady( fn ); 58 | } 59 | } 60 | }; 61 | 62 | whenReady(); 63 | } 64 | } ); 65 | 66 | // Make jQuery.ready Promise consumable (gh-1778) 67 | jQuery.ready.then = jQuery.fn.ready; 68 | 69 | /** 70 | * The ready event handler and self cleanup method 71 | */ 72 | function completed() { 73 | document.removeEventListener( "DOMContentLoaded", completed ); 74 | window.removeEventListener( "load", completed ); 75 | jQuery.ready(); 76 | } 77 | 78 | // Catch cases where $(document).ready() is called 79 | // after the browser event has already occurred. 80 | // Support: IE9-10 only 81 | // Older IE sometimes signals "interactive" too soon 82 | if ( document.readyState === "complete" || 83 | ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 84 | 85 | // Handle it asynchronously to allow scripts the opportunity to delay ready 86 | window.setTimeout( jQuery.ready ); 87 | 88 | } else { 89 | 90 | // Use the handy event callback 91 | document.addEventListener( "DOMContentLoaded", completed ); 92 | 93 | // A fallback to window.onload, that will always work 94 | window.addEventListener( "load", completed ); 95 | } 96 | 97 | } ); 98 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/traversing/findFilter.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/indexOf", 4 | "../var/isFunction", 5 | "./var/rneedsContext", 6 | "../selector" 7 | ], function( jQuery, indexOf, isFunction, rneedsContext ) { 8 | 9 | "use strict"; 10 | 11 | // Implement the identical functionality for filter and not 12 | function winnow( elements, qualifier, not ) { 13 | if ( isFunction( qualifier ) ) { 14 | return jQuery.grep( elements, function( elem, i ) { 15 | return !!qualifier.call( elem, i, elem ) !== not; 16 | } ); 17 | } 18 | 19 | // Single element 20 | if ( qualifier.nodeType ) { 21 | return jQuery.grep( elements, function( elem ) { 22 | return ( elem === qualifier ) !== not; 23 | } ); 24 | } 25 | 26 | // Arraylike of elements (jQuery, arguments, Array) 27 | if ( typeof qualifier !== "string" ) { 28 | return jQuery.grep( elements, function( elem ) { 29 | return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 30 | } ); 31 | } 32 | 33 | // Filtered directly for both simple and complex selectors 34 | return jQuery.filter( qualifier, elements, not ); 35 | } 36 | 37 | jQuery.filter = function( expr, elems, not ) { 38 | var elem = elems[ 0 ]; 39 | 40 | if ( not ) { 41 | expr = ":not(" + expr + ")"; 42 | } 43 | 44 | if ( elems.length === 1 && elem.nodeType === 1 ) { 45 | return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 46 | } 47 | 48 | return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 49 | return elem.nodeType === 1; 50 | } ) ); 51 | }; 52 | 53 | jQuery.fn.extend( { 54 | find: function( selector ) { 55 | var i, ret, 56 | len = this.length, 57 | self = this; 58 | 59 | if ( typeof selector !== "string" ) { 60 | return this.pushStack( jQuery( selector ).filter( function() { 61 | for ( i = 0; i < len; i++ ) { 62 | if ( jQuery.contains( self[ i ], this ) ) { 63 | return true; 64 | } 65 | } 66 | } ) ); 67 | } 68 | 69 | ret = this.pushStack( [] ); 70 | 71 | for ( i = 0; i < len; i++ ) { 72 | jQuery.find( selector, self[ i ], ret ); 73 | } 74 | 75 | return len > 1 ? jQuery.uniqueSort( ret ) : ret; 76 | }, 77 | filter: function( selector ) { 78 | return this.pushStack( winnow( this, selector || [], false ) ); 79 | }, 80 | not: function( selector ) { 81 | return this.pushStack( winnow( this, selector || [], true ) ); 82 | }, 83 | is: function( selector ) { 84 | return !!winnow( 85 | this, 86 | 87 | // If this is a positional/relative selector, check membership in the returned set 88 | // so $("p:first").is("p:last") won't return true for a doc with two "p". 89 | typeof selector === "string" && rneedsContext.test( selector ) ? 90 | jQuery( selector ) : 91 | selector || [], 92 | false 93 | ).length; 94 | } 95 | } ); 96 | 97 | } ); 98 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/showHide.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../data/var/dataPriv", 4 | "../css/var/isHiddenWithinTree" 5 | ], function( jQuery, dataPriv, isHiddenWithinTree ) { 6 | 7 | "use strict"; 8 | 9 | var defaultDisplayMap = {}; 10 | 11 | function getDefaultDisplay( elem ) { 12 | var temp, 13 | doc = elem.ownerDocument, 14 | nodeName = elem.nodeName, 15 | display = defaultDisplayMap[ nodeName ]; 16 | 17 | if ( display ) { 18 | return display; 19 | } 20 | 21 | temp = doc.body.appendChild( doc.createElement( nodeName ) ); 22 | display = jQuery.css( temp, "display" ); 23 | 24 | temp.parentNode.removeChild( temp ); 25 | 26 | if ( display === "none" ) { 27 | display = "block"; 28 | } 29 | defaultDisplayMap[ nodeName ] = display; 30 | 31 | return display; 32 | } 33 | 34 | function showHide( elements, show ) { 35 | var display, elem, 36 | values = [], 37 | index = 0, 38 | length = elements.length; 39 | 40 | // Determine new display value for elements that need to change 41 | for ( ; index < length; index++ ) { 42 | elem = elements[ index ]; 43 | if ( !elem.style ) { 44 | continue; 45 | } 46 | 47 | display = elem.style.display; 48 | if ( show ) { 49 | 50 | // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 51 | // check is required in this first loop unless we have a nonempty display value (either 52 | // inline or about-to-be-restored) 53 | if ( display === "none" ) { 54 | values[ index ] = dataPriv.get( elem, "display" ) || null; 55 | if ( !values[ index ] ) { 56 | elem.style.display = ""; 57 | } 58 | } 59 | if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 60 | values[ index ] = getDefaultDisplay( elem ); 61 | } 62 | } else { 63 | if ( display !== "none" ) { 64 | values[ index ] = "none"; 65 | 66 | // Remember what we're overwriting 67 | dataPriv.set( elem, "display", display ); 68 | } 69 | } 70 | } 71 | 72 | // Set the display of the elements in a second loop to avoid constant reflow 73 | for ( index = 0; index < length; index++ ) { 74 | if ( values[ index ] != null ) { 75 | elements[ index ].style.display = values[ index ]; 76 | } 77 | } 78 | 79 | return elements; 80 | } 81 | 82 | jQuery.fn.extend( { 83 | show: function() { 84 | return showHide( this, true ); 85 | }, 86 | hide: function() { 87 | return showHide( this ); 88 | }, 89 | toggle: function( state ) { 90 | if ( typeof state === "boolean" ) { 91 | return state ? this.show() : this.hide(); 92 | } 93 | 94 | return this.each( function() { 95 | if ( isHiddenWithinTree( this ) ) { 96 | jQuery( this ).show(); 97 | } else { 98 | jQuery( this ).hide(); 99 | } 100 | } ); 101 | } 102 | } ); 103 | 104 | return showHide; 105 | } ); 106 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/deprecated.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./core/nodeName", 4 | "./core/camelCase", 5 | "./core/toType", 6 | "./var/isFunction", 7 | "./var/isWindow", 8 | "./var/slice", 9 | 10 | "./event/alias" 11 | ], function( jQuery, nodeName, camelCase, toType, isFunction, isWindow, slice ) { 12 | 13 | "use strict"; 14 | 15 | jQuery.fn.extend( { 16 | 17 | bind: function( types, data, fn ) { 18 | return this.on( types, null, data, fn ); 19 | }, 20 | unbind: function( types, fn ) { 21 | return this.off( types, null, fn ); 22 | }, 23 | 24 | delegate: function( selector, types, data, fn ) { 25 | return this.on( types, selector, data, fn ); 26 | }, 27 | undelegate: function( selector, types, fn ) { 28 | 29 | // ( namespace ) or ( selector, types [, fn] ) 30 | return arguments.length === 1 ? 31 | this.off( selector, "**" ) : 32 | this.off( types, selector || "**", fn ); 33 | } 34 | } ); 35 | 36 | // Bind a function to a context, optionally partially applying any 37 | // arguments. 38 | // jQuery.proxy is deprecated to promote standards (specifically Function#bind) 39 | // However, it is not slated for removal any time soon 40 | jQuery.proxy = function( fn, context ) { 41 | var tmp, args, proxy; 42 | 43 | if ( typeof context === "string" ) { 44 | tmp = fn[ context ]; 45 | context = fn; 46 | fn = tmp; 47 | } 48 | 49 | // Quick check to determine if target is callable, in the spec 50 | // this throws a TypeError, but we will just return undefined. 51 | if ( !isFunction( fn ) ) { 52 | return undefined; 53 | } 54 | 55 | // Simulated bind 56 | args = slice.call( arguments, 2 ); 57 | proxy = function() { 58 | return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 59 | }; 60 | 61 | // Set the guid of unique handler to the same of original handler, so it can be removed 62 | proxy.guid = fn.guid = fn.guid || jQuery.guid++; 63 | 64 | return proxy; 65 | }; 66 | 67 | jQuery.holdReady = function( hold ) { 68 | if ( hold ) { 69 | jQuery.readyWait++; 70 | } else { 71 | jQuery.ready( true ); 72 | } 73 | }; 74 | jQuery.isArray = Array.isArray; 75 | jQuery.parseJSON = JSON.parse; 76 | jQuery.nodeName = nodeName; 77 | jQuery.isFunction = isFunction; 78 | jQuery.isWindow = isWindow; 79 | jQuery.camelCase = camelCase; 80 | jQuery.type = toType; 81 | 82 | jQuery.now = Date.now; 83 | 84 | jQuery.isNumeric = function( obj ) { 85 | 86 | // As of jQuery 3.0, isNumeric is limited to 87 | // strings and numbers (primitives or objects) 88 | // that can be coerced to finite numbers (gh-2662) 89 | var type = jQuery.type( obj ); 90 | return ( type === "number" || type === "string" ) && 91 | 92 | // parseFloat NaNs numeric-cast false positives ("") 93 | // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 94 | // subtraction forces infinities to NaN 95 | !isNaN( obj - parseFloat( obj ) ); 96 | }; 97 | 98 | } ); 99 | -------------------------------------------------------------------------------- /2. npm/2-7. 运行环境配置/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "cross-env": { 8 | "version": "6.0.3", 9 | "resolved": "https://registry.npm.taobao.org/cross-env/download/cross-env-6.0.3.tgz", 10 | "integrity": "sha1-Qla3HkmzpAY3oM5wdopu9ccq6UE=", 11 | "dev": true, 12 | "requires": { 13 | "cross-spawn": "^7.0.0" 14 | } 15 | }, 16 | "cross-spawn": { 17 | "version": "7.0.1", 18 | "resolved": "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.1.tgz?cache=0&sync_timestamp=1570508303786&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-spawn%2Fdownload%2Fcross-spawn-7.0.1.tgz", 19 | "integrity": "sha1-CrVihuD3wk4VPQTMKqAn5DqaXRQ=", 20 | "dev": true, 21 | "requires": { 22 | "path-key": "^3.1.0", 23 | "shebang-command": "^2.0.0", 24 | "which": "^2.0.1" 25 | } 26 | }, 27 | "isexe": { 28 | "version": "2.0.0", 29 | "resolved": "https://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz", 30 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", 31 | "dev": true 32 | }, 33 | "path-key": { 34 | "version": "3.1.1", 35 | "resolved": "https://registry.npm.taobao.org/path-key/download/path-key-3.1.1.tgz?cache=0&sync_timestamp=1574441520024&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpath-key%2Fdownload%2Fpath-key-3.1.1.tgz", 36 | "integrity": "sha1-WB9q3mWMu6ZaDTOA3ndTKVBU83U=", 37 | "dev": true 38 | }, 39 | "shebang-command": { 40 | "version": "2.0.0", 41 | "resolved": "https://registry.npm.taobao.org/shebang-command/download/shebang-command-2.0.0.tgz", 42 | "integrity": "sha1-zNCvT4g1+9wmW4JGGq8MNmY/NOo=", 43 | "dev": true, 44 | "requires": { 45 | "shebang-regex": "^3.0.0" 46 | } 47 | }, 48 | "shebang-regex": { 49 | "version": "3.0.0", 50 | "resolved": "https://registry.npm.taobao.org/shebang-regex/download/shebang-regex-3.0.0.tgz", 51 | "integrity": "sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=", 52 | "dev": true 53 | }, 54 | "which": { 55 | "version": "2.0.2", 56 | "resolved": "https://registry.npm.taobao.org/which/download/which-2.0.2.tgz?cache=0&sync_timestamp=1574116898193&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwhich%2Fdownload%2Fwhich-2.0.2.tgz", 57 | "integrity": "sha1-fGqN0KY2oDJ+ELWckobu6T8/UbE=", 58 | "dev": true, 59 | "requires": { 60 | "isexe": "^2.0.0" 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/movie.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "name": "爱尔兰人", 3 | "imgSrc": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2568902055.jpg", 4 | "detail": "2019-09-27(纽约电影节) / 2019-11-01(美国点映) / 2019-11-27(美国网络) / 罗伯特·德尼罗 / 阿尔·帕西诺 / 乔·佩西 / 安娜·帕奎因 / 杰西·普莱蒙 / 哈威·凯特尔 / 斯蒂芬·格拉汉姆 / 鲍比·坎纳瓦尔 / 杰克·休斯顿 / 阿莱卡萨·帕拉迪诺 / 凯瑟琳·纳杜奇..." 5 | }, { 6 | "name": "小丑", 7 | "imgSrc": "https://img9.doubanio.com/view/photo/s_ratio_poster/public/p2567198874.jpg", 8 | "detail": "2019-08-31(威尼斯电影节) / 2019-10-04(美国) / 杰昆·菲尼克斯 / 罗伯特·德尼罗 / 马克·马龙 / 莎姬·贝兹 / 谢伊·惠格姆 / 弗兰西丝·康罗伊 / 布莱恩·考伦 / 布莱恩·泰里·亨利 / 布莱特·卡伦 / 道格拉斯·霍奇斯 / 格伦·弗莱施勒 / 比尔·坎普..." 9 | }, { 10 | "name": "82年生的金智英", 11 | "imgSrc": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2570137991.jpg", 12 | "detail": "2019-10-23(韩国) / 2019-11-07(中国香港) / 郑有美 / 孔侑 / 金美京 / 孔敏晶 / 朴成妍 / 李凤莲 / 金圣喆 / 李乌 / 李海云 / 孙成灿 / 金正英 / 李娜云 / 禹志贤 / 廉惠兰 / 韩国 / 金度英 / 118分钟 / 82年生的金智英 / 剧情 / 刘英雅 Yeong-ah Yoo / 赵南珠..." 13 | }, { 14 | "name": "好莱坞往事", 15 | "imgSrc": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2551119672.jpg", 16 | "detail": "2019-05-21(戛纳电影节) / 2019-07-26(美国) / 2019(中国大陆) / 莱昂纳多·迪卡普里奥 / 布拉德·皮特 / 玛格特·罗比 / 埃米尔·赫斯基 / 玛格丽特·库里 / 蒂莫西·奥利芬特 / 茱莉亚·巴特斯 / 奥斯汀·巴特勒 / 达科塔·范宁 / 布鲁斯·邓恩 /..." 17 | }, { 18 | "name": "婚姻故事", 19 | "imgSrc": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2571760178.jpg", 20 | "detail": "2019-08-29(威尼斯电影节) / 2019-12-06(美国) / 斯嘉丽·约翰逊 / 亚当·德赖弗 / 梅里特·韦弗 / 劳拉·邓恩 / 雷·利奥塔 / 朱丽·哈基提 / 马克·奥布莱恩 / 华莱士·肖恩 / 阿伦·阿尔达 / 凯尔·柏海莫 / 米奇·萨姆纳 / 艾奇·罗伯逊 / 马修·马希尔..." 21 | }, { 22 | "name": "准备好了没", 23 | "imgSrc": "https://img9.doubanio.com/view/photo/s_ratio_poster/public/p2561370606.jpg", 24 | "detail": "2019-08-21(美国) / 萨玛拉·维文 / 安迪·麦克道威尔 / 马克·奥布莱恩 / 亚当·布罗迪 / 亨利·科泽尼 / 妮基·瓜达尼 / 梅兰妮·斯科洛凡诺 / 克里斯蒂安·布鲁恩 / 伊利斯 莱韦斯克 / 约翰·拉尔斯顿 / 达妮埃拉·巴博萨 / 伊拉娜·盖尔 /..." 25 | }, { 26 | "name": "克劳斯:圣诞节的秘密", 27 | "imgSrc": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2570825762.jpg", 28 | "detail": "2019-11-08(西班牙) / 2019-11-08(英国) / J·K·西蒙斯 / 詹森·舒瓦兹曼 / 拉什达·琼斯 / 琼·库萨克 / 诺曼·麦克唐纳徳 / 威尔·萨索 / 塞尔希奥·巴勃罗斯 / 米拉·布雷纳 / 内达·玛格丽特·拉巴 / 悉尼·布朗 / 泰迪·布鲁姆 / 艾玛·香农 / 肯德尔·卓依..." 29 | }, { 30 | "name": "第一滴血5:最后的血", 31 | "imgSrc": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2564884269.jpg", 32 | "detail": "2019-09-18(印度尼西亚) / 2019-09-20(美国) / 2019-09-27(西班牙) / 西尔维斯特·史泰龙 / 帕斯·贝加 / 塞尔吉奥·佩里斯-门切塔 / 艾德里安娜·巴拉扎 / 维特·蒙雷尔 / 吉妮·金 / 华金·科西奥 / 帕斯卡西奥·洛佩斯 / 奥斯卡·贾恩那达 / 亚历山大·迪米特罗夫..." 33 | }, { 34 | "name": "行骗天下JP:浪漫篇", 35 | "imgSrc": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2549891899.jpg", 36 | "detail": "2019-05-17(日本) / 长泽雅美 / 东出昌大 / 小日向文世 / 竹内结子 / 三浦春马 / 江口洋介 / 小手伸也 / 织田梨沙 / 前田敦子 / 小栗旬 / 佐津川爱美 / 冈田义德 / 生濑胜久 / 日本 / confidenceman-movie.com / 田中亮 / 116分钟 / 行骗天下JP:浪漫篇..." 37 | }, { 38 | "name": "纽约的一个雨天", 39 | "imgSrc": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2556824333.jpg", 40 | "detail": "2019-07-26(波兰) / 蒂莫西·柴勒梅德 / 艾丽·范宁 / 赛琳娜·戈麦斯 / 裘德·洛 / 迭戈·卢纳 / 列维·施瑞博尔 / 苏琪·沃特豪斯 / 凯莉·罗尔巴赫 / 丽贝卡·豪尔 / 安娜莱吉·阿什福特 / 切莉·琼斯 / 葛瑞芬·纽曼 / 凯瑟琳·利·斯科特 /..." 41 | }] -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/manipulation/buildFragment.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/toType", 4 | "../core/isAttached", 5 | "./var/rtagName", 6 | "./var/rscriptType", 7 | "./wrapMap", 8 | "./getAll", 9 | "./setGlobalEval" 10 | ], function( jQuery, toType, isAttached, rtagName, rscriptType, wrapMap, getAll, setGlobalEval ) { 11 | 12 | "use strict"; 13 | 14 | var rhtml = /<|&#?\w+;/; 15 | 16 | function buildFragment( elems, context, scripts, selection, ignored ) { 17 | var elem, tmp, tag, wrap, attached, j, 18 | fragment = context.createDocumentFragment(), 19 | nodes = [], 20 | i = 0, 21 | l = elems.length; 22 | 23 | for ( ; i < l; i++ ) { 24 | elem = elems[ i ]; 25 | 26 | if ( elem || elem === 0 ) { 27 | 28 | // Add nodes directly 29 | if ( toType( elem ) === "object" ) { 30 | 31 | // Support: Android <=4.0 only, PhantomJS 1 only 32 | // push.apply(_, arraylike) throws on ancient WebKit 33 | jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 34 | 35 | // Convert non-html into a text node 36 | } else if ( !rhtml.test( elem ) ) { 37 | nodes.push( context.createTextNode( elem ) ); 38 | 39 | // Convert html into DOM nodes 40 | } else { 41 | tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 42 | 43 | // Deserialize a standard representation 44 | tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 45 | wrap = wrapMap[ tag ] || wrapMap._default; 46 | tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 47 | 48 | // Descend through wrappers to the right content 49 | j = wrap[ 0 ]; 50 | while ( j-- ) { 51 | tmp = tmp.lastChild; 52 | } 53 | 54 | // Support: Android <=4.0 only, PhantomJS 1 only 55 | // push.apply(_, arraylike) throws on ancient WebKit 56 | jQuery.merge( nodes, tmp.childNodes ); 57 | 58 | // Remember the top-level container 59 | tmp = fragment.firstChild; 60 | 61 | // Ensure the created nodes are orphaned (#12392) 62 | tmp.textContent = ""; 63 | } 64 | } 65 | } 66 | 67 | // Remove wrapper from fragment 68 | fragment.textContent = ""; 69 | 70 | i = 0; 71 | while ( ( elem = nodes[ i++ ] ) ) { 72 | 73 | // Skip elements already in the context collection (trac-4087) 74 | if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 75 | if ( ignored ) { 76 | ignored.push( elem ); 77 | } 78 | continue; 79 | } 80 | 81 | attached = isAttached( elem ); 82 | 83 | // Append to fragment 84 | tmp = getAll( fragment.appendChild( elem ), "script" ); 85 | 86 | // Preserve script evaluation history 87 | if ( attached ) { 88 | setGlobalEval( tmp ); 89 | } 90 | 91 | // Capture executables 92 | if ( scripts ) { 93 | j = 0; 94 | while ( ( elem = tmp[ j++ ] ) ) { 95 | if ( rscriptType.test( elem.type || "" ) ) { 96 | scripts.push( elem ); 97 | } 98 | } 99 | } 100 | } 101 | 102 | return fragment; 103 | } 104 | 105 | return buildFragment; 106 | } ); 107 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/jsonp.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/isFunction", 4 | "./var/nonce", 5 | "./var/rquery", 6 | "../ajax" 7 | ], function( jQuery, isFunction, nonce, rquery ) { 8 | 9 | "use strict"; 10 | 11 | var oldCallbacks = [], 12 | rjsonp = /(=)\?(?=&|$)|\?\?/; 13 | 14 | // Default jsonp settings 15 | jQuery.ajaxSetup( { 16 | jsonp: "callback", 17 | jsonpCallback: function() { 18 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 19 | this[ callback ] = true; 20 | return callback; 21 | } 22 | } ); 23 | 24 | // Detect, normalize options and install callbacks for jsonp requests 25 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 26 | 27 | var callbackName, overwritten, responseContainer, 28 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 29 | "url" : 30 | typeof s.data === "string" && 31 | ( s.contentType || "" ) 32 | .indexOf( "application/x-www-form-urlencoded" ) === 0 && 33 | rjsonp.test( s.data ) && "data" 34 | ); 35 | 36 | // Handle iff the expected data type is "jsonp" or we have a parameter to set 37 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 38 | 39 | // Get callback name, remembering preexisting value associated with it 40 | callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 41 | s.jsonpCallback() : 42 | s.jsonpCallback; 43 | 44 | // Insert callback into url or form data 45 | if ( jsonProp ) { 46 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 47 | } else if ( s.jsonp !== false ) { 48 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 49 | } 50 | 51 | // Use data converter to retrieve json after script execution 52 | s.converters[ "script json" ] = function() { 53 | if ( !responseContainer ) { 54 | jQuery.error( callbackName + " was not called" ); 55 | } 56 | return responseContainer[ 0 ]; 57 | }; 58 | 59 | // Force json dataType 60 | s.dataTypes[ 0 ] = "json"; 61 | 62 | // Install callback 63 | overwritten = window[ callbackName ]; 64 | window[ callbackName ] = function() { 65 | responseContainer = arguments; 66 | }; 67 | 68 | // Clean-up function (fires after converters) 69 | jqXHR.always( function() { 70 | 71 | // If previous value didn't exist - remove it 72 | if ( overwritten === undefined ) { 73 | jQuery( window ).removeProp( callbackName ); 74 | 75 | // Otherwise restore preexisting value 76 | } else { 77 | window[ callbackName ] = overwritten; 78 | } 79 | 80 | // Save back as free 81 | if ( s[ callbackName ] ) { 82 | 83 | // Make sure that re-using the options doesn't screw things around 84 | s.jsonpCallback = originalSettings.jsonpCallback; 85 | 86 | // Save the callback name for future use 87 | oldCallbacks.push( callbackName ); 88 | } 89 | 90 | // Call if it was a function and we have a response 91 | if ( responseContainer && isFunction( overwritten ) ) { 92 | overwritten( responseContainer[ 0 ] ); 93 | } 94 | 95 | responseContainer = overwritten = undefined; 96 | } ); 97 | 98 | // Delegate to script 99 | return "script"; 100 | } 101 | } ); 102 | 103 | } ); 104 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/css/support.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "../var/documentElement", 5 | "../var/support" 6 | ], function( jQuery, document, documentElement, support ) { 7 | 8 | "use strict"; 9 | 10 | ( function() { 11 | 12 | // Executing both pixelPosition & boxSizingReliable tests require only one layout 13 | // so they're executed at the same time to save the second computation. 14 | function computeStyleTests() { 15 | 16 | // This is a singleton, we need to execute it only once 17 | if ( !div ) { 18 | return; 19 | } 20 | 21 | container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 22 | "margin-top:1px;padding:0;border:0"; 23 | div.style.cssText = 24 | "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 25 | "margin:auto;border:1px;padding:1px;" + 26 | "width:60%;top:1%"; 27 | documentElement.appendChild( container ).appendChild( div ); 28 | 29 | var divStyle = window.getComputedStyle( div ); 30 | pixelPositionVal = divStyle.top !== "1%"; 31 | 32 | // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 33 | reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 34 | 35 | // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 36 | // Some styles come back with percentage values, even though they shouldn't 37 | div.style.right = "60%"; 38 | pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 39 | 40 | // Support: IE 9 - 11 only 41 | // Detect misreporting of content dimensions for box-sizing:border-box elements 42 | boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 43 | 44 | // Support: IE 9 only 45 | // Detect overflow:scroll screwiness (gh-3699) 46 | // Support: Chrome <=64 47 | // Don't get tricked when zoom affects offsetWidth (gh-4029) 48 | div.style.position = "absolute"; 49 | scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; 50 | 51 | documentElement.removeChild( container ); 52 | 53 | // Nullify the div so it wouldn't be stored in the memory and 54 | // it will also be a sign that checks already performed 55 | div = null; 56 | } 57 | 58 | function roundPixelMeasures( measure ) { 59 | return Math.round( parseFloat( measure ) ); 60 | } 61 | 62 | var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 63 | reliableMarginLeftVal, 64 | container = document.createElement( "div" ), 65 | div = document.createElement( "div" ); 66 | 67 | // Finish early in limited (non-browser) environments 68 | if ( !div.style ) { 69 | return; 70 | } 71 | 72 | // Support: IE <=9 - 11 only 73 | // Style of cloned element affects source element cloned (#8908) 74 | div.style.backgroundClip = "content-box"; 75 | div.cloneNode( true ).style.backgroundClip = ""; 76 | support.clearCloneStyle = div.style.backgroundClip === "content-box"; 77 | 78 | jQuery.extend( support, { 79 | boxSizingReliable: function() { 80 | computeStyleTests(); 81 | return boxSizingReliableVal; 82 | }, 83 | pixelBoxStyles: function() { 84 | computeStyleTests(); 85 | return pixelBoxStylesVal; 86 | }, 87 | pixelPosition: function() { 88 | computeStyleTests(); 89 | return pixelPositionVal; 90 | }, 91 | reliableMarginLeft: function() { 92 | computeStyleTests(); 93 | return reliableMarginLeftVal; 94 | }, 95 | scrollboxSize: function() { 96 | computeStyleTests(); 97 | return scrollboxSizeVal; 98 | } 99 | } ); 100 | } )(); 101 | 102 | return support; 103 | 104 | } ); 105 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes/prop.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/access", 4 | "./support", 5 | "../selector" 6 | ], function( jQuery, access, support ) { 7 | 8 | "use strict"; 9 | 10 | var rfocusable = /^(?:input|select|textarea|button)$/i, 11 | rclickable = /^(?:a|area)$/i; 12 | 13 | jQuery.fn.extend( { 14 | prop: function( name, value ) { 15 | return access( this, jQuery.prop, name, value, arguments.length > 1 ); 16 | }, 17 | 18 | removeProp: function( name ) { 19 | return this.each( function() { 20 | delete this[ jQuery.propFix[ name ] || name ]; 21 | } ); 22 | } 23 | } ); 24 | 25 | jQuery.extend( { 26 | prop: function( elem, name, value ) { 27 | var ret, hooks, 28 | nType = elem.nodeType; 29 | 30 | // Don't get/set properties on text, comment and attribute nodes 31 | if ( nType === 3 || nType === 8 || nType === 2 ) { 32 | return; 33 | } 34 | 35 | if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 36 | 37 | // Fix name and attach hooks 38 | name = jQuery.propFix[ name ] || name; 39 | hooks = jQuery.propHooks[ name ]; 40 | } 41 | 42 | if ( value !== undefined ) { 43 | if ( hooks && "set" in hooks && 44 | ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 45 | return ret; 46 | } 47 | 48 | return ( elem[ name ] = value ); 49 | } 50 | 51 | if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 52 | return ret; 53 | } 54 | 55 | return elem[ name ]; 56 | }, 57 | 58 | propHooks: { 59 | tabIndex: { 60 | get: function( elem ) { 61 | 62 | // Support: IE <=9 - 11 only 63 | // elem.tabIndex doesn't always return the 64 | // correct value when it hasn't been explicitly set 65 | // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 66 | // Use proper attribute retrieval(#12072) 67 | var tabindex = jQuery.find.attr( elem, "tabindex" ); 68 | 69 | if ( tabindex ) { 70 | return parseInt( tabindex, 10 ); 71 | } 72 | 73 | if ( 74 | rfocusable.test( elem.nodeName ) || 75 | rclickable.test( elem.nodeName ) && 76 | elem.href 77 | ) { 78 | return 0; 79 | } 80 | 81 | return -1; 82 | } 83 | } 84 | }, 85 | 86 | propFix: { 87 | "for": "htmlFor", 88 | "class": "className" 89 | } 90 | } ); 91 | 92 | // Support: IE <=11 only 93 | // Accessing the selectedIndex property 94 | // forces the browser to respect setting selected 95 | // on the option 96 | // The getter ensures a default option is selected 97 | // when in an optgroup 98 | // eslint rule "no-unused-expressions" is disabled for this code 99 | // since it considers such accessions noop 100 | if ( !support.optSelected ) { 101 | jQuery.propHooks.selected = { 102 | get: function( elem ) { 103 | 104 | /* eslint no-unused-expressions: "off" */ 105 | 106 | var parent = elem.parentNode; 107 | if ( parent && parent.parentNode ) { 108 | parent.parentNode.selectedIndex; 109 | } 110 | return null; 111 | }, 112 | set: function( elem ) { 113 | 114 | /* eslint no-unused-expressions: "off" */ 115 | 116 | var parent = elem.parentNode; 117 | if ( parent ) { 118 | parent.selectedIndex; 119 | 120 | if ( parent.parentNode ) { 121 | parent.parentNode.selectedIndex; 122 | } 123 | } 124 | } 125 | }; 126 | } 127 | 128 | jQuery.each( [ 129 | "tabIndex", 130 | "readOnly", 131 | "maxLength", 132 | "cellSpacing", 133 | "cellPadding", 134 | "rowSpan", 135 | "colSpan", 136 | "useMap", 137 | "frameBorder", 138 | "contentEditable" 139 | ], function() { 140 | jQuery.propFix[ this.toLowerCase() ] = this; 141 | } ); 142 | 143 | } ); 144 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/queue.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./data/var/dataPriv", 4 | "./deferred", 5 | "./callbacks" 6 | ], function( jQuery, dataPriv ) { 7 | 8 | "use strict"; 9 | 10 | jQuery.extend( { 11 | queue: function( elem, type, data ) { 12 | var queue; 13 | 14 | if ( elem ) { 15 | type = ( type || "fx" ) + "queue"; 16 | queue = dataPriv.get( elem, type ); 17 | 18 | // Speed up dequeue by getting out quickly if this is just a lookup 19 | if ( data ) { 20 | if ( !queue || Array.isArray( data ) ) { 21 | queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 22 | } else { 23 | queue.push( data ); 24 | } 25 | } 26 | return queue || []; 27 | } 28 | }, 29 | 30 | dequeue: function( elem, type ) { 31 | type = type || "fx"; 32 | 33 | var queue = jQuery.queue( elem, type ), 34 | startLength = queue.length, 35 | fn = queue.shift(), 36 | hooks = jQuery._queueHooks( elem, type ), 37 | next = function() { 38 | jQuery.dequeue( elem, type ); 39 | }; 40 | 41 | // If the fx queue is dequeued, always remove the progress sentinel 42 | if ( fn === "inprogress" ) { 43 | fn = queue.shift(); 44 | startLength--; 45 | } 46 | 47 | if ( fn ) { 48 | 49 | // Add a progress sentinel to prevent the fx queue from being 50 | // automatically dequeued 51 | if ( type === "fx" ) { 52 | queue.unshift( "inprogress" ); 53 | } 54 | 55 | // Clear up the last queue stop function 56 | delete hooks.stop; 57 | fn.call( elem, next, hooks ); 58 | } 59 | 60 | if ( !startLength && hooks ) { 61 | hooks.empty.fire(); 62 | } 63 | }, 64 | 65 | // Not public - generate a queueHooks object, or return the current one 66 | _queueHooks: function( elem, type ) { 67 | var key = type + "queueHooks"; 68 | return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 69 | empty: jQuery.Callbacks( "once memory" ).add( function() { 70 | dataPriv.remove( elem, [ type + "queue", key ] ); 71 | } ) 72 | } ); 73 | } 74 | } ); 75 | 76 | jQuery.fn.extend( { 77 | queue: function( type, data ) { 78 | var setter = 2; 79 | 80 | if ( typeof type !== "string" ) { 81 | data = type; 82 | type = "fx"; 83 | setter--; 84 | } 85 | 86 | if ( arguments.length < setter ) { 87 | return jQuery.queue( this[ 0 ], type ); 88 | } 89 | 90 | return data === undefined ? 91 | this : 92 | this.each( function() { 93 | var queue = jQuery.queue( this, type, data ); 94 | 95 | // Ensure a hooks for this queue 96 | jQuery._queueHooks( this, type ); 97 | 98 | if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 99 | jQuery.dequeue( this, type ); 100 | } 101 | } ); 102 | }, 103 | dequeue: function( type ) { 104 | return this.each( function() { 105 | jQuery.dequeue( this, type ); 106 | } ); 107 | }, 108 | clearQueue: function( type ) { 109 | return this.queue( type || "fx", [] ); 110 | }, 111 | 112 | // Get a promise resolved when queues of a certain type 113 | // are emptied (fx is the type by default) 114 | promise: function( type, obj ) { 115 | var tmp, 116 | count = 1, 117 | defer = jQuery.Deferred(), 118 | elements = this, 119 | i = this.length, 120 | resolve = function() { 121 | if ( !( --count ) ) { 122 | defer.resolveWith( elements, [ elements ] ); 123 | } 124 | }; 125 | 126 | if ( typeof type !== "string" ) { 127 | obj = type; 128 | type = undefined; 129 | } 130 | type = type || "fx"; 131 | 132 | while ( i-- ) { 133 | tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 134 | if ( tmp && tmp.empty ) { 135 | count++; 136 | tmp.empty.add( resolve ); 137 | } 138 | } 139 | resolve(); 140 | return defer.promise( obj ); 141 | } 142 | } ); 143 | 144 | return jQuery; 145 | } ); 146 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/effects/Tween.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../css/finalPropName", 4 | 5 | "../css" 6 | ], function( jQuery, finalPropName ) { 7 | 8 | "use strict"; 9 | 10 | function Tween( elem, options, prop, end, easing ) { 11 | return new Tween.prototype.init( elem, options, prop, end, easing ); 12 | } 13 | jQuery.Tween = Tween; 14 | 15 | Tween.prototype = { 16 | constructor: Tween, 17 | init: function( elem, options, prop, end, easing, unit ) { 18 | this.elem = elem; 19 | this.prop = prop; 20 | this.easing = easing || jQuery.easing._default; 21 | this.options = options; 22 | this.start = this.now = this.cur(); 23 | this.end = end; 24 | this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 25 | }, 26 | cur: function() { 27 | var hooks = Tween.propHooks[ this.prop ]; 28 | 29 | return hooks && hooks.get ? 30 | hooks.get( this ) : 31 | Tween.propHooks._default.get( this ); 32 | }, 33 | run: function( percent ) { 34 | var eased, 35 | hooks = Tween.propHooks[ this.prop ]; 36 | 37 | if ( this.options.duration ) { 38 | this.pos = eased = jQuery.easing[ this.easing ]( 39 | percent, this.options.duration * percent, 0, 1, this.options.duration 40 | ); 41 | } else { 42 | this.pos = eased = percent; 43 | } 44 | this.now = ( this.end - this.start ) * eased + this.start; 45 | 46 | if ( this.options.step ) { 47 | this.options.step.call( this.elem, this.now, this ); 48 | } 49 | 50 | if ( hooks && hooks.set ) { 51 | hooks.set( this ); 52 | } else { 53 | Tween.propHooks._default.set( this ); 54 | } 55 | return this; 56 | } 57 | }; 58 | 59 | Tween.prototype.init.prototype = Tween.prototype; 60 | 61 | Tween.propHooks = { 62 | _default: { 63 | get: function( tween ) { 64 | var result; 65 | 66 | // Use a property on the element directly when it is not a DOM element, 67 | // or when there is no matching style property that exists. 68 | if ( tween.elem.nodeType !== 1 || 69 | tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 70 | return tween.elem[ tween.prop ]; 71 | } 72 | 73 | // Passing an empty string as a 3rd parameter to .css will automatically 74 | // attempt a parseFloat and fallback to a string if the parse fails. 75 | // Simple values such as "10px" are parsed to Float; 76 | // complex values such as "rotate(1rad)" are returned as-is. 77 | result = jQuery.css( tween.elem, tween.prop, "" ); 78 | 79 | // Empty strings, null, undefined and "auto" are converted to 0. 80 | return !result || result === "auto" ? 0 : result; 81 | }, 82 | set: function( tween ) { 83 | 84 | // Use step hook for back compat. 85 | // Use cssHook if its there. 86 | // Use .style if available and use plain properties where available. 87 | if ( jQuery.fx.step[ tween.prop ] ) { 88 | jQuery.fx.step[ tween.prop ]( tween ); 89 | } else if ( tween.elem.nodeType === 1 && ( 90 | jQuery.cssHooks[ tween.prop ] || 91 | tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { 92 | jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 93 | } else { 94 | tween.elem[ tween.prop ] = tween.now; 95 | } 96 | } 97 | } 98 | }; 99 | 100 | // Support: IE <=9 only 101 | // Panic based approach to setting things on disconnected nodes 102 | Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 103 | set: function( tween ) { 104 | if ( tween.elem.nodeType && tween.elem.parentNode ) { 105 | tween.elem[ tween.prop ] = tween.now; 106 | } 107 | } 108 | }; 109 | 110 | jQuery.easing = { 111 | linear: function( p ) { 112 | return p; 113 | }, 114 | swing: function( p ) { 115 | return 0.5 - Math.cos( p * Math.PI ) / 2; 116 | }, 117 | _default: "swing" 118 | }; 119 | 120 | jQuery.fx = Tween.prototype.init; 121 | 122 | // Back compat <1.8 extension point 123 | jQuery.fx.step = {}; 124 | 125 | } ); 126 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/serialize.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./core/toType", 4 | "./var/rcheckableType", 5 | "./var/isFunction", 6 | "./core/init", 7 | "./traversing", // filter 8 | "./attributes/prop" 9 | ], function( jQuery, toType, rcheckableType, isFunction ) { 10 | 11 | "use strict"; 12 | 13 | var 14 | rbracket = /\[\]$/, 15 | rCRLF = /\r?\n/g, 16 | rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 17 | rsubmittable = /^(?:input|select|textarea|keygen)/i; 18 | 19 | function buildParams( prefix, obj, traditional, add ) { 20 | var name; 21 | 22 | if ( Array.isArray( obj ) ) { 23 | 24 | // Serialize array item. 25 | jQuery.each( obj, function( i, v ) { 26 | if ( traditional || rbracket.test( prefix ) ) { 27 | 28 | // Treat each array item as a scalar. 29 | add( prefix, v ); 30 | 31 | } else { 32 | 33 | // Item is non-scalar (array or object), encode its numeric index. 34 | buildParams( 35 | prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 36 | v, 37 | traditional, 38 | add 39 | ); 40 | } 41 | } ); 42 | 43 | } else if ( !traditional && toType( obj ) === "object" ) { 44 | 45 | // Serialize object item. 46 | for ( name in obj ) { 47 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 48 | } 49 | 50 | } else { 51 | 52 | // Serialize scalar item. 53 | add( prefix, obj ); 54 | } 55 | } 56 | 57 | // Serialize an array of form elements or a set of 58 | // key/values into a query string 59 | jQuery.param = function( a, traditional ) { 60 | var prefix, 61 | s = [], 62 | add = function( key, valueOrFunction ) { 63 | 64 | // If value is a function, invoke it and use its return value 65 | var value = isFunction( valueOrFunction ) ? 66 | valueOrFunction() : 67 | valueOrFunction; 68 | 69 | s[ s.length ] = encodeURIComponent( key ) + "=" + 70 | encodeURIComponent( value == null ? "" : value ); 71 | }; 72 | 73 | if ( a == null ) { 74 | return ""; 75 | } 76 | 77 | // If an array was passed in, assume that it is an array of form elements. 78 | if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 79 | 80 | // Serialize the form elements 81 | jQuery.each( a, function() { 82 | add( this.name, this.value ); 83 | } ); 84 | 85 | } else { 86 | 87 | // If traditional, encode the "old" way (the way 1.3.2 or older 88 | // did it), otherwise encode params recursively. 89 | for ( prefix in a ) { 90 | buildParams( prefix, a[ prefix ], traditional, add ); 91 | } 92 | } 93 | 94 | // Return the resulting serialization 95 | return s.join( "&" ); 96 | }; 97 | 98 | jQuery.fn.extend( { 99 | serialize: function() { 100 | return jQuery.param( this.serializeArray() ); 101 | }, 102 | serializeArray: function() { 103 | return this.map( function() { 104 | 105 | // Can add propHook for "elements" to filter or add form elements 106 | var elements = jQuery.prop( this, "elements" ); 107 | return elements ? jQuery.makeArray( elements ) : this; 108 | } ) 109 | .filter( function() { 110 | var type = this.type; 111 | 112 | // Use .is( ":disabled" ) so that fieldset[disabled] works 113 | return this.name && !jQuery( this ).is( ":disabled" ) && 114 | rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 115 | ( this.checked || !rcheckableType.test( type ) ); 116 | } ) 117 | .map( function( i, elem ) { 118 | var val = jQuery( this ).val(); 119 | 120 | if ( val == null ) { 121 | return null; 122 | } 123 | 124 | if ( Array.isArray( val ) ) { 125 | return jQuery.map( val, function( val ) { 126 | return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 127 | } ); 128 | } 129 | 130 | return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 131 | } ).get(); 132 | } 133 | } ); 134 | 135 | return jQuery; 136 | } ); 137 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/core/init.js: -------------------------------------------------------------------------------- 1 | // Initialize a jQuery object 2 | define( [ 3 | "../core", 4 | "../var/document", 5 | "../var/isFunction", 6 | "./var/rsingleTag", 7 | 8 | "../traversing/findFilter" 9 | ], function( jQuery, document, isFunction, rsingleTag ) { 10 | 11 | "use strict"; 12 | 13 | // A central reference to the root jQuery(document) 14 | var rootjQuery, 15 | 16 | // A simple way to check for HTML strings 17 | // Prioritize #id over to avoid XSS via location.hash (#9521) 18 | // Strict HTML recognition (#11290: must start with <) 19 | // Shortcut simple #id case for speed 20 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 21 | 22 | init = jQuery.fn.init = function( selector, context, root ) { 23 | var match, elem; 24 | 25 | // HANDLE: $(""), $(null), $(undefined), $(false) 26 | if ( !selector ) { 27 | return this; 28 | } 29 | 30 | // Method init() accepts an alternate rootjQuery 31 | // so migrate can support jQuery.sub (gh-2101) 32 | root = root || rootjQuery; 33 | 34 | // Handle HTML strings 35 | if ( typeof selector === "string" ) { 36 | if ( selector[ 0 ] === "<" && 37 | selector[ selector.length - 1 ] === ">" && 38 | selector.length >= 3 ) { 39 | 40 | // Assume that strings that start and end with <> are HTML and skip the regex check 41 | match = [ null, selector, null ]; 42 | 43 | } else { 44 | match = rquickExpr.exec( selector ); 45 | } 46 | 47 | // Match html or make sure no context is specified for #id 48 | if ( match && ( match[ 1 ] || !context ) ) { 49 | 50 | // HANDLE: $(html) -> $(array) 51 | if ( match[ 1 ] ) { 52 | context = context instanceof jQuery ? context[ 0 ] : context; 53 | 54 | // Option to run scripts is true for back-compat 55 | // Intentionally let the error be thrown if parseHTML is not present 56 | jQuery.merge( this, jQuery.parseHTML( 57 | match[ 1 ], 58 | context && context.nodeType ? context.ownerDocument || context : document, 59 | true 60 | ) ); 61 | 62 | // HANDLE: $(html, props) 63 | if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 64 | for ( match in context ) { 65 | 66 | // Properties of context are called as methods if possible 67 | if ( isFunction( this[ match ] ) ) { 68 | this[ match ]( context[ match ] ); 69 | 70 | // ...and otherwise set as attributes 71 | } else { 72 | this.attr( match, context[ match ] ); 73 | } 74 | } 75 | } 76 | 77 | return this; 78 | 79 | // HANDLE: $(#id) 80 | } else { 81 | elem = document.getElementById( match[ 2 ] ); 82 | 83 | if ( elem ) { 84 | 85 | // Inject the element directly into the jQuery object 86 | this[ 0 ] = elem; 87 | this.length = 1; 88 | } 89 | return this; 90 | } 91 | 92 | // HANDLE: $(expr, $(...)) 93 | } else if ( !context || context.jquery ) { 94 | return ( context || root ).find( selector ); 95 | 96 | // HANDLE: $(expr, context) 97 | // (which is just equivalent to: $(context).find(expr) 98 | } else { 99 | return this.constructor( context ).find( selector ); 100 | } 101 | 102 | // HANDLE: $(DOMElement) 103 | } else if ( selector.nodeType ) { 104 | this[ 0 ] = selector; 105 | this.length = 1; 106 | return this; 107 | 108 | // HANDLE: $(function) 109 | // Shortcut for document ready 110 | } else if ( isFunction( selector ) ) { 111 | return root.ready !== undefined ? 112 | root.ready( selector ) : 113 | 114 | // Execute immediately if ready is not present 115 | selector( jQuery ); 116 | } 117 | 118 | return jQuery.makeArray( selector, this ); 119 | }; 120 | 121 | // Give the init function the jQuery prototype for later instantiation 122 | init.prototype = jQuery.fn; 123 | 124 | // Initialize central reference 125 | rootjQuery = jQuery( document ); 126 | 127 | return init; 128 | 129 | } ); 130 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes/attr.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/access", 4 | "../core/nodeName", 5 | "./support", 6 | "../var/rnothtmlwhite", 7 | "../selector" 8 | ], function( jQuery, access, nodeName, support, rnothtmlwhite ) { 9 | 10 | "use strict"; 11 | 12 | var boolHook, 13 | attrHandle = jQuery.expr.attrHandle; 14 | 15 | jQuery.fn.extend( { 16 | attr: function( name, value ) { 17 | return access( this, jQuery.attr, name, value, arguments.length > 1 ); 18 | }, 19 | 20 | removeAttr: function( name ) { 21 | return this.each( function() { 22 | jQuery.removeAttr( this, name ); 23 | } ); 24 | } 25 | } ); 26 | 27 | jQuery.extend( { 28 | attr: function( elem, name, value ) { 29 | var ret, hooks, 30 | nType = elem.nodeType; 31 | 32 | // Don't get/set attributes on text, comment and attribute nodes 33 | if ( nType === 3 || nType === 8 || nType === 2 ) { 34 | return; 35 | } 36 | 37 | // Fallback to prop when attributes are not supported 38 | if ( typeof elem.getAttribute === "undefined" ) { 39 | return jQuery.prop( elem, name, value ); 40 | } 41 | 42 | // Attribute hooks are determined by the lowercase version 43 | // Grab necessary hook if one is defined 44 | if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 45 | hooks = jQuery.attrHooks[ name.toLowerCase() ] || 46 | ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 47 | } 48 | 49 | if ( value !== undefined ) { 50 | if ( value === null ) { 51 | jQuery.removeAttr( elem, name ); 52 | return; 53 | } 54 | 55 | if ( hooks && "set" in hooks && 56 | ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 57 | return ret; 58 | } 59 | 60 | elem.setAttribute( name, value + "" ); 61 | return value; 62 | } 63 | 64 | if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 65 | return ret; 66 | } 67 | 68 | ret = jQuery.find.attr( elem, name ); 69 | 70 | // Non-existent attributes return null, we normalize to undefined 71 | return ret == null ? undefined : ret; 72 | }, 73 | 74 | attrHooks: { 75 | type: { 76 | set: function( elem, value ) { 77 | if ( !support.radioValue && value === "radio" && 78 | nodeName( elem, "input" ) ) { 79 | var val = elem.value; 80 | elem.setAttribute( "type", value ); 81 | if ( val ) { 82 | elem.value = val; 83 | } 84 | return value; 85 | } 86 | } 87 | } 88 | }, 89 | 90 | removeAttr: function( elem, value ) { 91 | var name, 92 | i = 0, 93 | 94 | // Attribute names can contain non-HTML whitespace characters 95 | // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 96 | attrNames = value && value.match( rnothtmlwhite ); 97 | 98 | if ( attrNames && elem.nodeType === 1 ) { 99 | while ( ( name = attrNames[ i++ ] ) ) { 100 | elem.removeAttribute( name ); 101 | } 102 | } 103 | } 104 | } ); 105 | 106 | // Hooks for boolean attributes 107 | boolHook = { 108 | set: function( elem, value, name ) { 109 | if ( value === false ) { 110 | 111 | // Remove boolean attributes when set to false 112 | jQuery.removeAttr( elem, name ); 113 | } else { 114 | elem.setAttribute( name, name ); 115 | } 116 | return name; 117 | } 118 | }; 119 | 120 | jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { 121 | var getter = attrHandle[ name ] || jQuery.find.attr; 122 | 123 | attrHandle[ name ] = function( elem, name, isXML ) { 124 | var ret, handle, 125 | lowercaseName = name.toLowerCase(); 126 | 127 | if ( !isXML ) { 128 | 129 | // Avoid an infinite loop by temporarily removing this function from the getter 130 | handle = attrHandle[ lowercaseName ]; 131 | attrHandle[ lowercaseName ] = ret; 132 | ret = getter( elem, name, isXML ) != null ? 133 | lowercaseName : 134 | null; 135 | attrHandle[ lowercaseName ] = handle; 136 | } 137 | return ret; 138 | }; 139 | } ); 140 | 141 | } ); 142 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/data/Data.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/camelCase", 4 | "../var/rnothtmlwhite", 5 | "./var/acceptData" 6 | ], function( jQuery, camelCase, rnothtmlwhite, acceptData ) { 7 | 8 | "use strict"; 9 | 10 | function Data() { 11 | this.expando = jQuery.expando + Data.uid++; 12 | } 13 | 14 | Data.uid = 1; 15 | 16 | Data.prototype = { 17 | 18 | cache: function( owner ) { 19 | 20 | // Check if the owner object already has a cache 21 | var value = owner[ this.expando ]; 22 | 23 | // If not, create one 24 | if ( !value ) { 25 | value = {}; 26 | 27 | // We can accept data for non-element nodes in modern browsers, 28 | // but we should not, see #8335. 29 | // Always return an empty object. 30 | if ( acceptData( owner ) ) { 31 | 32 | // If it is a node unlikely to be stringify-ed or looped over 33 | // use plain assignment 34 | if ( owner.nodeType ) { 35 | owner[ this.expando ] = value; 36 | 37 | // Otherwise secure it in a non-enumerable property 38 | // configurable must be true to allow the property to be 39 | // deleted when data is removed 40 | } else { 41 | Object.defineProperty( owner, this.expando, { 42 | value: value, 43 | configurable: true 44 | } ); 45 | } 46 | } 47 | } 48 | 49 | return value; 50 | }, 51 | set: function( owner, data, value ) { 52 | var prop, 53 | cache = this.cache( owner ); 54 | 55 | // Handle: [ owner, key, value ] args 56 | // Always use camelCase key (gh-2257) 57 | if ( typeof data === "string" ) { 58 | cache[ camelCase( data ) ] = value; 59 | 60 | // Handle: [ owner, { properties } ] args 61 | } else { 62 | 63 | // Copy the properties one-by-one to the cache object 64 | for ( prop in data ) { 65 | cache[ camelCase( prop ) ] = data[ prop ]; 66 | } 67 | } 68 | return cache; 69 | }, 70 | get: function( owner, key ) { 71 | return key === undefined ? 72 | this.cache( owner ) : 73 | 74 | // Always use camelCase key (gh-2257) 75 | owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 76 | }, 77 | access: function( owner, key, value ) { 78 | 79 | // In cases where either: 80 | // 81 | // 1. No key was specified 82 | // 2. A string key was specified, but no value provided 83 | // 84 | // Take the "read" path and allow the get method to determine 85 | // which value to return, respectively either: 86 | // 87 | // 1. The entire cache object 88 | // 2. The data stored at the key 89 | // 90 | if ( key === undefined || 91 | ( ( key && typeof key === "string" ) && value === undefined ) ) { 92 | 93 | return this.get( owner, key ); 94 | } 95 | 96 | // When the key is not a string, or both a key and value 97 | // are specified, set or extend (existing objects) with either: 98 | // 99 | // 1. An object of properties 100 | // 2. A key and value 101 | // 102 | this.set( owner, key, value ); 103 | 104 | // Since the "set" path can have two possible entry points 105 | // return the expected data based on which path was taken[*] 106 | return value !== undefined ? value : key; 107 | }, 108 | remove: function( owner, key ) { 109 | var i, 110 | cache = owner[ this.expando ]; 111 | 112 | if ( cache === undefined ) { 113 | return; 114 | } 115 | 116 | if ( key !== undefined ) { 117 | 118 | // Support array or space separated string of keys 119 | if ( Array.isArray( key ) ) { 120 | 121 | // If key is an array of keys... 122 | // We always set camelCase keys, so remove that. 123 | key = key.map( camelCase ); 124 | } else { 125 | key = camelCase( key ); 126 | 127 | // If a key with the spaces exists, use it. 128 | // Otherwise, create an array by matching non-whitespace 129 | key = key in cache ? 130 | [ key ] : 131 | ( key.match( rnothtmlwhite ) || [] ); 132 | } 133 | 134 | i = key.length; 135 | 136 | while ( i-- ) { 137 | delete cache[ key[ i ] ]; 138 | } 139 | } 140 | 141 | // Remove the expando if there's no more data 142 | if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 143 | 144 | // Support: Chrome <=35 - 45 145 | // Webkit & Blink performance suffers when deleting properties 146 | // from DOM nodes, so set to undefined instead 147 | // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 148 | if ( owner.nodeType ) { 149 | owner[ this.expando ] = undefined; 150 | } else { 151 | delete owner[ this.expando ]; 152 | } 153 | } 154 | }, 155 | hasData: function( owner ) { 156 | var cache = owner[ this.expando ]; 157 | return cache !== undefined && !jQuery.isEmptyObject( cache ); 158 | } 159 | }; 160 | 161 | return Data; 162 | } ); 163 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/ajax/xhr.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/support", 4 | "../ajax" 5 | ], function( jQuery, support ) { 6 | 7 | "use strict"; 8 | 9 | jQuery.ajaxSettings.xhr = function() { 10 | try { 11 | return new window.XMLHttpRequest(); 12 | } catch ( e ) {} 13 | }; 14 | 15 | var xhrSuccessStatus = { 16 | 17 | // File protocol always yields status code 0, assume 200 18 | 0: 200, 19 | 20 | // Support: IE <=9 only 21 | // #1450: sometimes IE returns 1223 when it should be 204 22 | 1223: 204 23 | }, 24 | xhrSupported = jQuery.ajaxSettings.xhr(); 25 | 26 | support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 27 | support.ajax = xhrSupported = !!xhrSupported; 28 | 29 | jQuery.ajaxTransport( function( options ) { 30 | var callback, errorCallback; 31 | 32 | // Cross domain only allowed if supported through XMLHttpRequest 33 | if ( support.cors || xhrSupported && !options.crossDomain ) { 34 | return { 35 | send: function( headers, complete ) { 36 | var i, 37 | xhr = options.xhr(); 38 | 39 | xhr.open( 40 | options.type, 41 | options.url, 42 | options.async, 43 | options.username, 44 | options.password 45 | ); 46 | 47 | // Apply custom fields if provided 48 | if ( options.xhrFields ) { 49 | for ( i in options.xhrFields ) { 50 | xhr[ i ] = options.xhrFields[ i ]; 51 | } 52 | } 53 | 54 | // Override mime type if needed 55 | if ( options.mimeType && xhr.overrideMimeType ) { 56 | xhr.overrideMimeType( options.mimeType ); 57 | } 58 | 59 | // X-Requested-With header 60 | // For cross-domain requests, seeing as conditions for a preflight are 61 | // akin to a jigsaw puzzle, we simply never set it to be sure. 62 | // (it can always be set on a per-request basis or even using ajaxSetup) 63 | // For same-domain requests, won't change header if already provided. 64 | if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 65 | headers[ "X-Requested-With" ] = "XMLHttpRequest"; 66 | } 67 | 68 | // Set headers 69 | for ( i in headers ) { 70 | xhr.setRequestHeader( i, headers[ i ] ); 71 | } 72 | 73 | // Callback 74 | callback = function( type ) { 75 | return function() { 76 | if ( callback ) { 77 | callback = errorCallback = xhr.onload = 78 | xhr.onerror = xhr.onabort = xhr.ontimeout = 79 | xhr.onreadystatechange = null; 80 | 81 | if ( type === "abort" ) { 82 | xhr.abort(); 83 | } else if ( type === "error" ) { 84 | 85 | // Support: IE <=9 only 86 | // On a manual native abort, IE9 throws 87 | // errors on any property access that is not readyState 88 | if ( typeof xhr.status !== "number" ) { 89 | complete( 0, "error" ); 90 | } else { 91 | complete( 92 | 93 | // File: protocol always yields status 0; see #8605, #14207 94 | xhr.status, 95 | xhr.statusText 96 | ); 97 | } 98 | } else { 99 | complete( 100 | xhrSuccessStatus[ xhr.status ] || xhr.status, 101 | xhr.statusText, 102 | 103 | // Support: IE <=9 only 104 | // IE9 has no XHR2 but throws on binary (trac-11426) 105 | // For XHR2 non-text, let the caller handle it (gh-2498) 106 | ( xhr.responseType || "text" ) !== "text" || 107 | typeof xhr.responseText !== "string" ? 108 | { binary: xhr.response } : 109 | { text: xhr.responseText }, 110 | xhr.getAllResponseHeaders() 111 | ); 112 | } 113 | } 114 | }; 115 | }; 116 | 117 | // Listen to events 118 | xhr.onload = callback(); 119 | errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 120 | 121 | // Support: IE 9 only 122 | // Use onreadystatechange to replace onabort 123 | // to handle uncaught aborts 124 | if ( xhr.onabort !== undefined ) { 125 | xhr.onabort = errorCallback; 126 | } else { 127 | xhr.onreadystatechange = function() { 128 | 129 | // Check readyState before timeout as it changes 130 | if ( xhr.readyState === 4 ) { 131 | 132 | // Allow onerror to be called first, 133 | // but that will not handle a native abort 134 | // Also, save errorCallback to a variable 135 | // as xhr.onerror cannot be accessed 136 | window.setTimeout( function() { 137 | if ( callback ) { 138 | errorCallback(); 139 | } 140 | } ); 141 | } 142 | }; 143 | } 144 | 145 | // Create the abort callback 146 | callback = callback( "abort" ); 147 | 148 | try { 149 | 150 | // Do send the request (this may raise an exception) 151 | xhr.send( options.hasContent && options.data || null ); 152 | } catch ( e ) { 153 | 154 | // #14683: Only rethrow if this hasn't been notified as an error yet 155 | if ( callback ) { 156 | throw e; 157 | } 158 | } 159 | }, 160 | 161 | abort: function() { 162 | if ( callback ) { 163 | callback(); 164 | } 165 | } 166 | }; 167 | } 168 | } ); 169 | 170 | } ); 171 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes/val.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/stripAndCollapse", 4 | "./support", 5 | "../core/nodeName", 6 | "../var/isFunction", 7 | 8 | "../core/init" 9 | ], function( jQuery, stripAndCollapse, support, nodeName, isFunction ) { 10 | 11 | "use strict"; 12 | 13 | var rreturn = /\r/g; 14 | 15 | jQuery.fn.extend( { 16 | val: function( value ) { 17 | var hooks, ret, valueIsFunction, 18 | elem = this[ 0 ]; 19 | 20 | if ( !arguments.length ) { 21 | if ( elem ) { 22 | hooks = jQuery.valHooks[ elem.type ] || 23 | jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 24 | 25 | if ( hooks && 26 | "get" in hooks && 27 | ( ret = hooks.get( elem, "value" ) ) !== undefined 28 | ) { 29 | return ret; 30 | } 31 | 32 | ret = elem.value; 33 | 34 | // Handle most common string cases 35 | if ( typeof ret === "string" ) { 36 | return ret.replace( rreturn, "" ); 37 | } 38 | 39 | // Handle cases where value is null/undef or number 40 | return ret == null ? "" : ret; 41 | } 42 | 43 | return; 44 | } 45 | 46 | valueIsFunction = isFunction( value ); 47 | 48 | return this.each( function( i ) { 49 | var val; 50 | 51 | if ( this.nodeType !== 1 ) { 52 | return; 53 | } 54 | 55 | if ( valueIsFunction ) { 56 | val = value.call( this, i, jQuery( this ).val() ); 57 | } else { 58 | val = value; 59 | } 60 | 61 | // Treat null/undefined as ""; convert numbers to string 62 | if ( val == null ) { 63 | val = ""; 64 | 65 | } else if ( typeof val === "number" ) { 66 | val += ""; 67 | 68 | } else if ( Array.isArray( val ) ) { 69 | val = jQuery.map( val, function( value ) { 70 | return value == null ? "" : value + ""; 71 | } ); 72 | } 73 | 74 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 75 | 76 | // If set returns undefined, fall back to normal setting 77 | if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 78 | this.value = val; 79 | } 80 | } ); 81 | } 82 | } ); 83 | 84 | jQuery.extend( { 85 | valHooks: { 86 | option: { 87 | get: function( elem ) { 88 | 89 | var val = jQuery.find.attr( elem, "value" ); 90 | return val != null ? 91 | val : 92 | 93 | // Support: IE <=10 - 11 only 94 | // option.text throws exceptions (#14686, #14858) 95 | // Strip and collapse whitespace 96 | // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 97 | stripAndCollapse( jQuery.text( elem ) ); 98 | } 99 | }, 100 | select: { 101 | get: function( elem ) { 102 | var value, option, i, 103 | options = elem.options, 104 | index = elem.selectedIndex, 105 | one = elem.type === "select-one", 106 | values = one ? null : [], 107 | max = one ? index + 1 : options.length; 108 | 109 | if ( index < 0 ) { 110 | i = max; 111 | 112 | } else { 113 | i = one ? index : 0; 114 | } 115 | 116 | // Loop through all the selected options 117 | for ( ; i < max; i++ ) { 118 | option = options[ i ]; 119 | 120 | // Support: IE <=9 only 121 | // IE8-9 doesn't update selected after form reset (#2551) 122 | if ( ( option.selected || i === index ) && 123 | 124 | // Don't return options that are disabled or in a disabled optgroup 125 | !option.disabled && 126 | ( !option.parentNode.disabled || 127 | !nodeName( option.parentNode, "optgroup" ) ) ) { 128 | 129 | // Get the specific value for the option 130 | value = jQuery( option ).val(); 131 | 132 | // We don't need an array for one selects 133 | if ( one ) { 134 | return value; 135 | } 136 | 137 | // Multi-Selects return an array 138 | values.push( value ); 139 | } 140 | } 141 | 142 | return values; 143 | }, 144 | 145 | set: function( elem, value ) { 146 | var optionSet, option, 147 | options = elem.options, 148 | values = jQuery.makeArray( value ), 149 | i = options.length; 150 | 151 | while ( i-- ) { 152 | option = options[ i ]; 153 | 154 | /* eslint-disable no-cond-assign */ 155 | 156 | if ( option.selected = 157 | jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 158 | ) { 159 | optionSet = true; 160 | } 161 | 162 | /* eslint-enable no-cond-assign */ 163 | } 164 | 165 | // Force browsers to behave consistently when non-matching value is set 166 | if ( !optionSet ) { 167 | elem.selectedIndex = -1; 168 | } 169 | return values; 170 | } 171 | } 172 | } 173 | } ); 174 | 175 | // Radios and checkboxes getter/setter 176 | jQuery.each( [ "radio", "checkbox" ], function() { 177 | jQuery.valHooks[ this ] = { 178 | set: function( elem, value ) { 179 | if ( Array.isArray( value ) ) { 180 | return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 181 | } 182 | } 183 | }; 184 | if ( !support.checkOn ) { 185 | jQuery.valHooks[ this ].get = function( elem ) { 186 | return elem.getAttribute( "value" ) === null ? "on" : elem.value; 187 | }; 188 | } 189 | } ); 190 | 191 | } ); 192 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/data.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./core/access", 4 | "./core/camelCase", 5 | "./data/var/dataPriv", 6 | "./data/var/dataUser" 7 | ], function( jQuery, access, camelCase, dataPriv, dataUser ) { 8 | 9 | "use strict"; 10 | 11 | // Implementation Summary 12 | // 13 | // 1. Enforce API surface and semantic compatibility with 1.9.x branch 14 | // 2. Improve the module's maintainability by reducing the storage 15 | // paths to a single mechanism. 16 | // 3. Use the same single mechanism to support "private" and "user" data. 17 | // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 18 | // 5. Avoid exposing implementation details on user objects (eg. expando properties) 19 | // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 20 | 21 | var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 22 | rmultiDash = /[A-Z]/g; 23 | 24 | function getData( data ) { 25 | if ( data === "true" ) { 26 | return true; 27 | } 28 | 29 | if ( data === "false" ) { 30 | return false; 31 | } 32 | 33 | if ( data === "null" ) { 34 | return null; 35 | } 36 | 37 | // Only convert to a number if it doesn't change the string 38 | if ( data === +data + "" ) { 39 | return +data; 40 | } 41 | 42 | if ( rbrace.test( data ) ) { 43 | return JSON.parse( data ); 44 | } 45 | 46 | return data; 47 | } 48 | 49 | function dataAttr( elem, key, data ) { 50 | var name; 51 | 52 | // If nothing was found internally, try to fetch any 53 | // data from the HTML5 data-* attribute 54 | if ( data === undefined && elem.nodeType === 1 ) { 55 | name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 56 | data = elem.getAttribute( name ); 57 | 58 | if ( typeof data === "string" ) { 59 | try { 60 | data = getData( data ); 61 | } catch ( e ) {} 62 | 63 | // Make sure we set the data so it isn't changed later 64 | dataUser.set( elem, key, data ); 65 | } else { 66 | data = undefined; 67 | } 68 | } 69 | return data; 70 | } 71 | 72 | jQuery.extend( { 73 | hasData: function( elem ) { 74 | return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 75 | }, 76 | 77 | data: function( elem, name, data ) { 78 | return dataUser.access( elem, name, data ); 79 | }, 80 | 81 | removeData: function( elem, name ) { 82 | dataUser.remove( elem, name ); 83 | }, 84 | 85 | // TODO: Now that all calls to _data and _removeData have been replaced 86 | // with direct calls to dataPriv methods, these can be deprecated. 87 | _data: function( elem, name, data ) { 88 | return dataPriv.access( elem, name, data ); 89 | }, 90 | 91 | _removeData: function( elem, name ) { 92 | dataPriv.remove( elem, name ); 93 | } 94 | } ); 95 | 96 | jQuery.fn.extend( { 97 | data: function( key, value ) { 98 | var i, name, data, 99 | elem = this[ 0 ], 100 | attrs = elem && elem.attributes; 101 | 102 | // Gets all values 103 | if ( key === undefined ) { 104 | if ( this.length ) { 105 | data = dataUser.get( elem ); 106 | 107 | if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 108 | i = attrs.length; 109 | while ( i-- ) { 110 | 111 | // Support: IE 11 only 112 | // The attrs elements can be null (#14894) 113 | if ( attrs[ i ] ) { 114 | name = attrs[ i ].name; 115 | if ( name.indexOf( "data-" ) === 0 ) { 116 | name = camelCase( name.slice( 5 ) ); 117 | dataAttr( elem, name, data[ name ] ); 118 | } 119 | } 120 | } 121 | dataPriv.set( elem, "hasDataAttrs", true ); 122 | } 123 | } 124 | 125 | return data; 126 | } 127 | 128 | // Sets multiple values 129 | if ( typeof key === "object" ) { 130 | return this.each( function() { 131 | dataUser.set( this, key ); 132 | } ); 133 | } 134 | 135 | return access( this, function( value ) { 136 | var data; 137 | 138 | // The calling jQuery object (element matches) is not empty 139 | // (and therefore has an element appears at this[ 0 ]) and the 140 | // `value` parameter was not undefined. An empty jQuery object 141 | // will result in `undefined` for elem = this[ 0 ] which will 142 | // throw an exception if an attempt to read a data cache is made. 143 | if ( elem && value === undefined ) { 144 | 145 | // Attempt to get data from the cache 146 | // The key will always be camelCased in Data 147 | data = dataUser.get( elem, key ); 148 | if ( data !== undefined ) { 149 | return data; 150 | } 151 | 152 | // Attempt to "discover" the data in 153 | // HTML5 custom data-* attrs 154 | data = dataAttr( elem, key ); 155 | if ( data !== undefined ) { 156 | return data; 157 | } 158 | 159 | // We tried really hard, but the data doesn't exist. 160 | return; 161 | } 162 | 163 | // Set the data... 164 | this.each( function() { 165 | 166 | // We always store the camelCased key 167 | dataUser.set( this, key, value ); 168 | } ); 169 | }, null, value, arguments.length > 1, null, true ); 170 | }, 171 | 172 | removeData: function( key ) { 173 | return this.each( function() { 174 | dataUser.remove( this, key ); 175 | } ); 176 | } 177 | } ); 178 | 179 | return jQuery; 180 | } ); 181 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/attributes/classes.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../core/stripAndCollapse", 4 | "../var/isFunction", 5 | "../var/rnothtmlwhite", 6 | "../data/var/dataPriv", 7 | "../core/init" 8 | ], function( jQuery, stripAndCollapse, isFunction, rnothtmlwhite, dataPriv ) { 9 | 10 | "use strict"; 11 | 12 | function getClass( elem ) { 13 | return elem.getAttribute && elem.getAttribute( "class" ) || ""; 14 | } 15 | 16 | function classesToArray( value ) { 17 | if ( Array.isArray( value ) ) { 18 | return value; 19 | } 20 | if ( typeof value === "string" ) { 21 | return value.match( rnothtmlwhite ) || []; 22 | } 23 | return []; 24 | } 25 | 26 | jQuery.fn.extend( { 27 | addClass: function( value ) { 28 | var classes, elem, cur, curValue, clazz, j, finalValue, 29 | i = 0; 30 | 31 | if ( isFunction( value ) ) { 32 | return this.each( function( j ) { 33 | jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 34 | } ); 35 | } 36 | 37 | classes = classesToArray( value ); 38 | 39 | if ( classes.length ) { 40 | while ( ( elem = this[ i++ ] ) ) { 41 | curValue = getClass( elem ); 42 | cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 43 | 44 | if ( cur ) { 45 | j = 0; 46 | while ( ( clazz = classes[ j++ ] ) ) { 47 | if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 48 | cur += clazz + " "; 49 | } 50 | } 51 | 52 | // Only assign if different to avoid unneeded rendering. 53 | finalValue = stripAndCollapse( cur ); 54 | if ( curValue !== finalValue ) { 55 | elem.setAttribute( "class", finalValue ); 56 | } 57 | } 58 | } 59 | } 60 | 61 | return this; 62 | }, 63 | 64 | removeClass: function( value ) { 65 | var classes, elem, cur, curValue, clazz, j, finalValue, 66 | i = 0; 67 | 68 | if ( isFunction( value ) ) { 69 | return this.each( function( j ) { 70 | jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 71 | } ); 72 | } 73 | 74 | if ( !arguments.length ) { 75 | return this.attr( "class", "" ); 76 | } 77 | 78 | classes = classesToArray( value ); 79 | 80 | if ( classes.length ) { 81 | while ( ( elem = this[ i++ ] ) ) { 82 | curValue = getClass( elem ); 83 | 84 | // This expression is here for better compressibility (see addClass) 85 | cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 86 | 87 | if ( cur ) { 88 | j = 0; 89 | while ( ( clazz = classes[ j++ ] ) ) { 90 | 91 | // Remove *all* instances 92 | while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 93 | cur = cur.replace( " " + clazz + " ", " " ); 94 | } 95 | } 96 | 97 | // Only assign if different to avoid unneeded rendering. 98 | finalValue = stripAndCollapse( cur ); 99 | if ( curValue !== finalValue ) { 100 | elem.setAttribute( "class", finalValue ); 101 | } 102 | } 103 | } 104 | } 105 | 106 | return this; 107 | }, 108 | 109 | toggleClass: function( value, stateVal ) { 110 | var type = typeof value, 111 | isValidValue = type === "string" || Array.isArray( value ); 112 | 113 | if ( typeof stateVal === "boolean" && isValidValue ) { 114 | return stateVal ? this.addClass( value ) : this.removeClass( value ); 115 | } 116 | 117 | if ( isFunction( value ) ) { 118 | return this.each( function( i ) { 119 | jQuery( this ).toggleClass( 120 | value.call( this, i, getClass( this ), stateVal ), 121 | stateVal 122 | ); 123 | } ); 124 | } 125 | 126 | return this.each( function() { 127 | var className, i, self, classNames; 128 | 129 | if ( isValidValue ) { 130 | 131 | // Toggle individual class names 132 | i = 0; 133 | self = jQuery( this ); 134 | classNames = classesToArray( value ); 135 | 136 | while ( ( className = classNames[ i++ ] ) ) { 137 | 138 | // Check each className given, space separated list 139 | if ( self.hasClass( className ) ) { 140 | self.removeClass( className ); 141 | } else { 142 | self.addClass( className ); 143 | } 144 | } 145 | 146 | // Toggle whole class name 147 | } else if ( value === undefined || type === "boolean" ) { 148 | className = getClass( this ); 149 | if ( className ) { 150 | 151 | // Store className if set 152 | dataPriv.set( this, "__className__", className ); 153 | } 154 | 155 | // If the element has a class name or if we're passed `false`, 156 | // then remove the whole classname (if there was one, the above saved it). 157 | // Otherwise bring back whatever was previously saved (if anything), 158 | // falling back to the empty string if nothing was stored. 159 | if ( this.setAttribute ) { 160 | this.setAttribute( "class", 161 | className || value === false ? 162 | "" : 163 | dataPriv.get( this, "__className__" ) || "" 164 | ); 165 | } 166 | } 167 | } ); 168 | }, 169 | 170 | hasClass: function( selector ) { 171 | var className, elem, 172 | i = 0; 173 | 174 | className = " " + selector + " "; 175 | while ( ( elem = this[ i++ ] ) ) { 176 | if ( elem.nodeType === 1 && 177 | ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 178 | return true; 179 | } 180 | } 181 | 182 | return false; 183 | } 184 | } ); 185 | 186 | } ); 187 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/traversing.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./var/indexOf", 4 | "./traversing/var/dir", 5 | "./traversing/var/siblings", 6 | "./traversing/var/rneedsContext", 7 | "./core/nodeName", 8 | 9 | "./core/init", 10 | "./traversing/findFilter", 11 | "./selector" 12 | ], function( jQuery, indexOf, dir, siblings, rneedsContext, nodeName ) { 13 | 14 | "use strict"; 15 | 16 | var rparentsprev = /^(?:parents|prev(?:Until|All))/, 17 | 18 | // Methods guaranteed to produce a unique set when starting from a unique set 19 | guaranteedUnique = { 20 | children: true, 21 | contents: true, 22 | next: true, 23 | prev: true 24 | }; 25 | 26 | jQuery.fn.extend( { 27 | has: function( target ) { 28 | var targets = jQuery( target, this ), 29 | l = targets.length; 30 | 31 | return this.filter( function() { 32 | var i = 0; 33 | for ( ; i < l; i++ ) { 34 | if ( jQuery.contains( this, targets[ i ] ) ) { 35 | return true; 36 | } 37 | } 38 | } ); 39 | }, 40 | 41 | closest: function( selectors, context ) { 42 | var cur, 43 | i = 0, 44 | l = this.length, 45 | matched = [], 46 | targets = typeof selectors !== "string" && jQuery( selectors ); 47 | 48 | // Positional selectors never match, since there's no _selection_ context 49 | if ( !rneedsContext.test( selectors ) ) { 50 | for ( ; i < l; i++ ) { 51 | for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 52 | 53 | // Always skip document fragments 54 | if ( cur.nodeType < 11 && ( targets ? 55 | targets.index( cur ) > -1 : 56 | 57 | // Don't pass non-elements to Sizzle 58 | cur.nodeType === 1 && 59 | jQuery.find.matchesSelector( cur, selectors ) ) ) { 60 | 61 | matched.push( cur ); 62 | break; 63 | } 64 | } 65 | } 66 | } 67 | 68 | return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 69 | }, 70 | 71 | // Determine the position of an element within the set 72 | index: function( elem ) { 73 | 74 | // No argument, return index in parent 75 | if ( !elem ) { 76 | return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 77 | } 78 | 79 | // Index in selector 80 | if ( typeof elem === "string" ) { 81 | return indexOf.call( jQuery( elem ), this[ 0 ] ); 82 | } 83 | 84 | // Locate the position of the desired element 85 | return indexOf.call( this, 86 | 87 | // If it receives a jQuery object, the first element is used 88 | elem.jquery ? elem[ 0 ] : elem 89 | ); 90 | }, 91 | 92 | add: function( selector, context ) { 93 | return this.pushStack( 94 | jQuery.uniqueSort( 95 | jQuery.merge( this.get(), jQuery( selector, context ) ) 96 | ) 97 | ); 98 | }, 99 | 100 | addBack: function( selector ) { 101 | return this.add( selector == null ? 102 | this.prevObject : this.prevObject.filter( selector ) 103 | ); 104 | } 105 | } ); 106 | 107 | function sibling( cur, dir ) { 108 | while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 109 | return cur; 110 | } 111 | 112 | jQuery.each( { 113 | parent: function( elem ) { 114 | var parent = elem.parentNode; 115 | return parent && parent.nodeType !== 11 ? parent : null; 116 | }, 117 | parents: function( elem ) { 118 | return dir( elem, "parentNode" ); 119 | }, 120 | parentsUntil: function( elem, i, until ) { 121 | return dir( elem, "parentNode", until ); 122 | }, 123 | next: function( elem ) { 124 | return sibling( elem, "nextSibling" ); 125 | }, 126 | prev: function( elem ) { 127 | return sibling( elem, "previousSibling" ); 128 | }, 129 | nextAll: function( elem ) { 130 | return dir( elem, "nextSibling" ); 131 | }, 132 | prevAll: function( elem ) { 133 | return dir( elem, "previousSibling" ); 134 | }, 135 | nextUntil: function( elem, i, until ) { 136 | return dir( elem, "nextSibling", until ); 137 | }, 138 | prevUntil: function( elem, i, until ) { 139 | return dir( elem, "previousSibling", until ); 140 | }, 141 | siblings: function( elem ) { 142 | return siblings( ( elem.parentNode || {} ).firstChild, elem ); 143 | }, 144 | children: function( elem ) { 145 | return siblings( elem.firstChild ); 146 | }, 147 | contents: function( elem ) { 148 | if ( typeof elem.contentDocument !== "undefined" ) { 149 | return elem.contentDocument; 150 | } 151 | 152 | // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 153 | // Treat the template element as a regular one in browsers that 154 | // don't support it. 155 | if ( nodeName( elem, "template" ) ) { 156 | elem = elem.content || elem; 157 | } 158 | 159 | return jQuery.merge( [], elem.childNodes ); 160 | } 161 | }, function( name, fn ) { 162 | jQuery.fn[ name ] = function( until, selector ) { 163 | var matched = jQuery.map( this, fn, until ); 164 | 165 | if ( name.slice( -5 ) !== "Until" ) { 166 | selector = until; 167 | } 168 | 169 | if ( selector && typeof selector === "string" ) { 170 | matched = jQuery.filter( selector, matched ); 171 | } 172 | 173 | if ( this.length > 1 ) { 174 | 175 | // Remove duplicates 176 | if ( !guaranteedUnique[ name ] ) { 177 | jQuery.uniqueSort( matched ); 178 | } 179 | 180 | // Reverse order for parents* and prev-derivatives 181 | if ( rparentsprev.test( name ) ) { 182 | matched.reverse(); 183 | } 184 | } 185 | 186 | return this.pushStack( matched ); 187 | }; 188 | } ); 189 | 190 | return jQuery; 191 | } ); 192 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/event/trigger.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "../core", 3 | "../var/document", 4 | "../data/var/dataPriv", 5 | "../data/var/acceptData", 6 | "../var/hasOwn", 7 | "../var/isFunction", 8 | "../var/isWindow", 9 | "../event" 10 | ], function( jQuery, document, dataPriv, acceptData, hasOwn, isFunction, isWindow ) { 11 | 12 | "use strict"; 13 | 14 | var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 15 | stopPropagationCallback = function( e ) { 16 | e.stopPropagation(); 17 | }; 18 | 19 | jQuery.extend( jQuery.event, { 20 | 21 | trigger: function( event, data, elem, onlyHandlers ) { 22 | 23 | var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 24 | eventPath = [ elem || document ], 25 | type = hasOwn.call( event, "type" ) ? event.type : event, 26 | namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 27 | 28 | cur = lastElement = tmp = elem = elem || document; 29 | 30 | // Don't do events on text and comment nodes 31 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 32 | return; 33 | } 34 | 35 | // focus/blur morphs to focusin/out; ensure we're not firing them right now 36 | if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 37 | return; 38 | } 39 | 40 | if ( type.indexOf( "." ) > -1 ) { 41 | 42 | // Namespaced trigger; create a regexp to match event type in handle() 43 | namespaces = type.split( "." ); 44 | type = namespaces.shift(); 45 | namespaces.sort(); 46 | } 47 | ontype = type.indexOf( ":" ) < 0 && "on" + type; 48 | 49 | // Caller can pass in a jQuery.Event object, Object, or just an event type string 50 | event = event[ jQuery.expando ] ? 51 | event : 52 | new jQuery.Event( type, typeof event === "object" && event ); 53 | 54 | // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 55 | event.isTrigger = onlyHandlers ? 2 : 3; 56 | event.namespace = namespaces.join( "." ); 57 | event.rnamespace = event.namespace ? 58 | new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 59 | null; 60 | 61 | // Clean up the event in case it is being reused 62 | event.result = undefined; 63 | if ( !event.target ) { 64 | event.target = elem; 65 | } 66 | 67 | // Clone any incoming data and prepend the event, creating the handler arg list 68 | data = data == null ? 69 | [ event ] : 70 | jQuery.makeArray( data, [ event ] ); 71 | 72 | // Allow special events to draw outside the lines 73 | special = jQuery.event.special[ type ] || {}; 74 | if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 75 | return; 76 | } 77 | 78 | // Determine event propagation path in advance, per W3C events spec (#9951) 79 | // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 80 | if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 81 | 82 | bubbleType = special.delegateType || type; 83 | if ( !rfocusMorph.test( bubbleType + type ) ) { 84 | cur = cur.parentNode; 85 | } 86 | for ( ; cur; cur = cur.parentNode ) { 87 | eventPath.push( cur ); 88 | tmp = cur; 89 | } 90 | 91 | // Only add window if we got to document (e.g., not plain obj or detached DOM) 92 | if ( tmp === ( elem.ownerDocument || document ) ) { 93 | eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 94 | } 95 | } 96 | 97 | // Fire handlers on the event path 98 | i = 0; 99 | while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 100 | lastElement = cur; 101 | event.type = i > 1 ? 102 | bubbleType : 103 | special.bindType || type; 104 | 105 | // jQuery handler 106 | handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && 107 | dataPriv.get( cur, "handle" ); 108 | if ( handle ) { 109 | handle.apply( cur, data ); 110 | } 111 | 112 | // Native handler 113 | handle = ontype && cur[ ontype ]; 114 | if ( handle && handle.apply && acceptData( cur ) ) { 115 | event.result = handle.apply( cur, data ); 116 | if ( event.result === false ) { 117 | event.preventDefault(); 118 | } 119 | } 120 | } 121 | event.type = type; 122 | 123 | // If nobody prevented the default action, do it now 124 | if ( !onlyHandlers && !event.isDefaultPrevented() ) { 125 | 126 | if ( ( !special._default || 127 | special._default.apply( eventPath.pop(), data ) === false ) && 128 | acceptData( elem ) ) { 129 | 130 | // Call a native DOM method on the target with the same name as the event. 131 | // Don't do default actions on window, that's where global variables be (#6170) 132 | if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 133 | 134 | // Don't re-trigger an onFOO event when we call its FOO() method 135 | tmp = elem[ ontype ]; 136 | 137 | if ( tmp ) { 138 | elem[ ontype ] = null; 139 | } 140 | 141 | // Prevent re-triggering of the same event, since we already bubbled it above 142 | jQuery.event.triggered = type; 143 | 144 | if ( event.isPropagationStopped() ) { 145 | lastElement.addEventListener( type, stopPropagationCallback ); 146 | } 147 | 148 | elem[ type ](); 149 | 150 | if ( event.isPropagationStopped() ) { 151 | lastElement.removeEventListener( type, stopPropagationCallback ); 152 | } 153 | 154 | jQuery.event.triggered = undefined; 155 | 156 | if ( tmp ) { 157 | elem[ ontype ] = tmp; 158 | } 159 | } 160 | } 161 | } 162 | 163 | return event.result; 164 | }, 165 | 166 | // Piggyback on a donor event to simulate a different one 167 | // Used only for `focus(in | out)` events 168 | simulate: function( type, elem, event ) { 169 | var e = jQuery.extend( 170 | new jQuery.Event(), 171 | event, 172 | { 173 | type: type, 174 | isSimulated: true 175 | } 176 | ); 177 | 178 | jQuery.event.trigger( e, null, elem ); 179 | } 180 | 181 | } ); 182 | 183 | jQuery.fn.extend( { 184 | 185 | trigger: function( type, data ) { 186 | return this.each( function() { 187 | jQuery.event.trigger( type, data, this ); 188 | } ); 189 | }, 190 | triggerHandler: function( type, data ) { 191 | var elem = this[ 0 ]; 192 | if ( elem ) { 193 | return jQuery.event.trigger( type, data, elem, true ); 194 | } 195 | } 196 | } ); 197 | 198 | return jQuery; 199 | } ); 200 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/callbacks.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./core/toType", 4 | "./var/isFunction", 5 | "./var/rnothtmlwhite" 6 | ], function( jQuery, toType, isFunction, rnothtmlwhite ) { 7 | 8 | "use strict"; 9 | 10 | // Convert String-formatted options into Object-formatted ones 11 | function createOptions( options ) { 12 | var object = {}; 13 | jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 14 | object[ flag ] = true; 15 | } ); 16 | return object; 17 | } 18 | 19 | /* 20 | * Create a callback list using the following parameters: 21 | * 22 | * options: an optional list of space-separated options that will change how 23 | * the callback list behaves or a more traditional option object 24 | * 25 | * By default a callback list will act like an event callback list and can be 26 | * "fired" multiple times. 27 | * 28 | * Possible options: 29 | * 30 | * once: will ensure the callback list can only be fired once (like a Deferred) 31 | * 32 | * memory: will keep track of previous values and will call any callback added 33 | * after the list has been fired right away with the latest "memorized" 34 | * values (like a Deferred) 35 | * 36 | * unique: will ensure a callback can only be added once (no duplicate in the list) 37 | * 38 | * stopOnFalse: interrupt callings when a callback returns false 39 | * 40 | */ 41 | jQuery.Callbacks = function( options ) { 42 | 43 | // Convert options from String-formatted to Object-formatted if needed 44 | // (we check in cache first) 45 | options = typeof options === "string" ? 46 | createOptions( options ) : 47 | jQuery.extend( {}, options ); 48 | 49 | var // Flag to know if list is currently firing 50 | firing, 51 | 52 | // Last fire value for non-forgettable lists 53 | memory, 54 | 55 | // Flag to know if list was already fired 56 | fired, 57 | 58 | // Flag to prevent firing 59 | locked, 60 | 61 | // Actual callback list 62 | list = [], 63 | 64 | // Queue of execution data for repeatable lists 65 | queue = [], 66 | 67 | // Index of currently firing callback (modified by add/remove as needed) 68 | firingIndex = -1, 69 | 70 | // Fire callbacks 71 | fire = function() { 72 | 73 | // Enforce single-firing 74 | locked = locked || options.once; 75 | 76 | // Execute callbacks for all pending executions, 77 | // respecting firingIndex overrides and runtime changes 78 | fired = firing = true; 79 | for ( ; queue.length; firingIndex = -1 ) { 80 | memory = queue.shift(); 81 | while ( ++firingIndex < list.length ) { 82 | 83 | // Run callback and check for early termination 84 | if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 85 | options.stopOnFalse ) { 86 | 87 | // Jump to end and forget the data so .add doesn't re-fire 88 | firingIndex = list.length; 89 | memory = false; 90 | } 91 | } 92 | } 93 | 94 | // Forget the data if we're done with it 95 | if ( !options.memory ) { 96 | memory = false; 97 | } 98 | 99 | firing = false; 100 | 101 | // Clean up if we're done firing for good 102 | if ( locked ) { 103 | 104 | // Keep an empty list if we have data for future add calls 105 | if ( memory ) { 106 | list = []; 107 | 108 | // Otherwise, this object is spent 109 | } else { 110 | list = ""; 111 | } 112 | } 113 | }, 114 | 115 | // Actual Callbacks object 116 | self = { 117 | 118 | // Add a callback or a collection of callbacks to the list 119 | add: function() { 120 | if ( list ) { 121 | 122 | // If we have memory from a past run, we should fire after adding 123 | if ( memory && !firing ) { 124 | firingIndex = list.length - 1; 125 | queue.push( memory ); 126 | } 127 | 128 | ( function add( args ) { 129 | jQuery.each( args, function( _, arg ) { 130 | if ( isFunction( arg ) ) { 131 | if ( !options.unique || !self.has( arg ) ) { 132 | list.push( arg ); 133 | } 134 | } else if ( arg && arg.length && toType( arg ) !== "string" ) { 135 | 136 | // Inspect recursively 137 | add( arg ); 138 | } 139 | } ); 140 | } )( arguments ); 141 | 142 | if ( memory && !firing ) { 143 | fire(); 144 | } 145 | } 146 | return this; 147 | }, 148 | 149 | // Remove a callback from the list 150 | remove: function() { 151 | jQuery.each( arguments, function( _, arg ) { 152 | var index; 153 | while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 154 | list.splice( index, 1 ); 155 | 156 | // Handle firing indexes 157 | if ( index <= firingIndex ) { 158 | firingIndex--; 159 | } 160 | } 161 | } ); 162 | return this; 163 | }, 164 | 165 | // Check if a given callback is in the list. 166 | // If no argument is given, return whether or not list has callbacks attached. 167 | has: function( fn ) { 168 | return fn ? 169 | jQuery.inArray( fn, list ) > -1 : 170 | list.length > 0; 171 | }, 172 | 173 | // Remove all callbacks from the list 174 | empty: function() { 175 | if ( list ) { 176 | list = []; 177 | } 178 | return this; 179 | }, 180 | 181 | // Disable .fire and .add 182 | // Abort any current/pending executions 183 | // Clear all callbacks and values 184 | disable: function() { 185 | locked = queue = []; 186 | list = memory = ""; 187 | return this; 188 | }, 189 | disabled: function() { 190 | return !list; 191 | }, 192 | 193 | // Disable .fire 194 | // Also disable .add unless we have memory (since it would have no effect) 195 | // Abort any pending executions 196 | lock: function() { 197 | locked = queue = []; 198 | if ( !memory && !firing ) { 199 | list = memory = ""; 200 | } 201 | return this; 202 | }, 203 | locked: function() { 204 | return !!locked; 205 | }, 206 | 207 | // Call all callbacks with the given context and arguments 208 | fireWith: function( context, args ) { 209 | if ( !locked ) { 210 | args = args || []; 211 | args = [ context, args.slice ? args.slice() : args ]; 212 | queue.push( args ); 213 | if ( !firing ) { 214 | fire(); 215 | } 216 | } 217 | return this; 218 | }, 219 | 220 | // Call all the callbacks with the given arguments 221 | fire: function() { 222 | self.fireWith( this, arguments ); 223 | return this; 224 | }, 225 | 226 | // To know if the callbacks have already been called at least once 227 | fired: function() { 228 | return !!fired; 229 | } 230 | }; 231 | 232 | return self; 233 | }; 234 | 235 | return jQuery; 236 | } ); 237 | -------------------------------------------------------------------------------- /4. 其他包管理器/4-5. bower/bower_components/jquery/src/selector-native.js: -------------------------------------------------------------------------------- 1 | define( [ 2 | "./core", 3 | "./var/document", 4 | "./var/documentElement", 5 | "./var/hasOwn", 6 | "./var/indexOf" 7 | ], function( jQuery, document, documentElement, hasOwn, indexOf ) { 8 | 9 | "use strict"; 10 | 11 | /* 12 | * Optional (non-Sizzle) selector module for custom builds. 13 | * 14 | * Note that this DOES NOT SUPPORT many documented jQuery 15 | * features in exchange for its smaller size: 16 | * 17 | * Attribute not equal selector 18 | * Positional selectors (:first; :eq(n); :odd; etc.) 19 | * Type selectors (:input; :checkbox; :button; etc.) 20 | * State-based selectors (:animated; :visible; :hidden; etc.) 21 | * :has(selector) 22 | * :not(complex selector) 23 | * custom selectors via Sizzle extensions 24 | * Leading combinators (e.g., $collection.find("> *")) 25 | * Reliable functionality on XML fragments 26 | * Requiring all parts of a selector to match elements under context 27 | * (e.g., $div.find("div > *") now matches children of $div) 28 | * Matching against non-elements 29 | * Reliable sorting of disconnected nodes 30 | * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit) 31 | * 32 | * If any of these are unacceptable tradeoffs, either use Sizzle or 33 | * customize this stub for the project's specific needs. 34 | */ 35 | 36 | var hasDuplicate, sortInput, 37 | sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando, 38 | matches = documentElement.matches || 39 | documentElement.webkitMatchesSelector || 40 | documentElement.mozMatchesSelector || 41 | documentElement.oMatchesSelector || 42 | documentElement.msMatchesSelector, 43 | 44 | // CSS string/identifier serialization 45 | // https://drafts.csswg.org/cssom/#common-serializing-idioms 46 | rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g, 47 | fcssescape = function( ch, asCodePoint ) { 48 | if ( asCodePoint ) { 49 | 50 | // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 51 | if ( ch === "\0" ) { 52 | return "\uFFFD"; 53 | } 54 | 55 | // Control characters and (dependent upon position) numbers get escaped as code points 56 | return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 57 | } 58 | 59 | // Other potentially-special ASCII characters get backslash-escaped 60 | return "\\" + ch; 61 | }; 62 | 63 | function sortOrder( a, b ) { 64 | 65 | // Flag for duplicate removal 66 | if ( a === b ) { 67 | hasDuplicate = true; 68 | return 0; 69 | } 70 | 71 | // Sort on method existence if only one input has compareDocumentPosition 72 | var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 73 | if ( compare ) { 74 | return compare; 75 | } 76 | 77 | // Calculate position if both inputs belong to the same document 78 | compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? 79 | a.compareDocumentPosition( b ) : 80 | 81 | // Otherwise we know they are disconnected 82 | 1; 83 | 84 | // Disconnected nodes 85 | if ( compare & 1 ) { 86 | 87 | // Choose the first element that is related to our preferred document 88 | if ( a === document || a.ownerDocument === document && 89 | jQuery.contains( document, a ) ) { 90 | return -1; 91 | } 92 | if ( b === document || b.ownerDocument === document && 93 | jQuery.contains( document, b ) ) { 94 | return 1; 95 | } 96 | 97 | // Maintain original order 98 | return sortInput ? 99 | ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : 100 | 0; 101 | } 102 | 103 | return compare & 4 ? -1 : 1; 104 | } 105 | 106 | function uniqueSort( results ) { 107 | var elem, 108 | duplicates = [], 109 | j = 0, 110 | i = 0; 111 | 112 | hasDuplicate = false; 113 | sortInput = !sortStable && results.slice( 0 ); 114 | results.sort( sortOrder ); 115 | 116 | if ( hasDuplicate ) { 117 | while ( ( elem = results[ i++ ] ) ) { 118 | if ( elem === results[ i ] ) { 119 | j = duplicates.push( i ); 120 | } 121 | } 122 | while ( j-- ) { 123 | results.splice( duplicates[ j ], 1 ); 124 | } 125 | } 126 | 127 | // Clear input after sorting to release objects 128 | // See https://github.com/jquery/sizzle/pull/225 129 | sortInput = null; 130 | 131 | return results; 132 | } 133 | 134 | function escape( sel ) { 135 | return ( sel + "" ).replace( rcssescape, fcssescape ); 136 | } 137 | 138 | jQuery.extend( { 139 | uniqueSort: uniqueSort, 140 | unique: uniqueSort, 141 | escapeSelector: escape, 142 | find: function( selector, context, results, seed ) { 143 | var elem, nodeType, 144 | i = 0; 145 | 146 | results = results || []; 147 | context = context || document; 148 | 149 | // Same basic safeguard as Sizzle 150 | if ( !selector || typeof selector !== "string" ) { 151 | return results; 152 | } 153 | 154 | // Early return if context is not an element or document 155 | if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) { 156 | return []; 157 | } 158 | 159 | if ( seed ) { 160 | while ( ( elem = seed[ i++ ] ) ) { 161 | if ( jQuery.find.matchesSelector( elem, selector ) ) { 162 | results.push( elem ); 163 | } 164 | } 165 | } else { 166 | jQuery.merge( results, context.querySelectorAll( selector ) ); 167 | } 168 | 169 | return results; 170 | }, 171 | text: function( elem ) { 172 | var node, 173 | ret = "", 174 | i = 0, 175 | nodeType = elem.nodeType; 176 | 177 | if ( !nodeType ) { 178 | 179 | // If no nodeType, this is expected to be an array 180 | while ( ( node = elem[ i++ ] ) ) { 181 | 182 | // Do not traverse comment nodes 183 | ret += jQuery.text( node ); 184 | } 185 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 186 | 187 | // Use textContent for elements 188 | return elem.textContent; 189 | } else if ( nodeType === 3 || nodeType === 4 ) { 190 | return elem.nodeValue; 191 | } 192 | 193 | // Do not include comment or processing instruction nodes 194 | 195 | return ret; 196 | }, 197 | contains: function( a, b ) { 198 | var adown = a.nodeType === 9 ? a.documentElement : a, 199 | bup = b && b.parentNode; 200 | return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) ); 201 | }, 202 | isXMLDoc: function( elem ) { 203 | 204 | // documentElement is verified for cases where it doesn't yet exist 205 | // (such as loading iframes in IE - #4833) 206 | var documentElement = elem && ( elem.ownerDocument || elem ).documentElement; 207 | return documentElement ? documentElement.nodeName !== "HTML" : false; 208 | }, 209 | expr: { 210 | attrHandle: {}, 211 | match: { 212 | bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" + 213 | "|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ), 214 | needsContext: /^[\x20\t\r\n\f]*[>+~]/ 215 | } 216 | } 217 | } ); 218 | 219 | jQuery.extend( jQuery.find, { 220 | matches: function( expr, elements ) { 221 | return jQuery.find( expr, null, null, elements ); 222 | }, 223 | matchesSelector: function( elem, expr ) { 224 | return matches.call( elem, expr ); 225 | }, 226 | attr: function( elem, name ) { 227 | var fn = jQuery.expr.attrHandle[ name.toLowerCase() ], 228 | 229 | // Don't get fooled by Object.prototype properties (jQuery #13807) 230 | value = fn && hasOwn.call( jQuery.expr.attrHandle, name.toLowerCase() ) ? 231 | fn( elem, name, jQuery.isXMLDoc( elem ) ) : 232 | undefined; 233 | return value !== undefined ? value : elem.getAttribute( name ); 234 | } 235 | } ); 236 | 237 | } ); 238 | -------------------------------------------------------------------------------- /2. npm/2-4. 练习-简易数据爬虫/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chapter2", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "12.12.18", 9 | "resolved": "https://registry.npm.taobao.org/@types/node/download/@types/node-12.12.18.tgz?cache=0&sync_timestamp=1576499222199&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-12.12.18.tgz", 10 | "integrity": "sha1-jRZjR5fWPCr1vGR86Hn43iC1ZGk=" 11 | }, 12 | "axios": { 13 | "version": "0.19.0", 14 | "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.19.0.tgz", 15 | "integrity": "sha1-jgm/89kSLhM/e4EByPvdAO09Krg=", 16 | "requires": { 17 | "follow-redirects": "1.5.10", 18 | "is-buffer": "^2.0.2" 19 | } 20 | }, 21 | "boolbase": { 22 | "version": "1.0.0", 23 | "resolved": "https://registry.npm.taobao.org/boolbase/download/boolbase-1.0.0.tgz", 24 | "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" 25 | }, 26 | "cheerio": { 27 | "version": "1.0.0-rc.3", 28 | "resolved": "https://registry.npm.taobao.org/cheerio/download/cheerio-1.0.0-rc.3.tgz", 29 | "integrity": "sha1-CUY21CWy6cD065GkbAVjDJoai/Y=", 30 | "requires": { 31 | "css-select": "~1.2.0", 32 | "dom-serializer": "~0.1.1", 33 | "entities": "~1.1.1", 34 | "htmlparser2": "^3.9.1", 35 | "lodash": "^4.15.0", 36 | "parse5": "^3.0.1" 37 | } 38 | }, 39 | "css-select": { 40 | "version": "1.2.0", 41 | "resolved": "https://registry.npm.taobao.org/css-select/download/css-select-1.2.0.tgz", 42 | "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", 43 | "requires": { 44 | "boolbase": "~1.0.0", 45 | "css-what": "2.1", 46 | "domutils": "1.5.1", 47 | "nth-check": "~1.0.1" 48 | } 49 | }, 50 | "css-what": { 51 | "version": "2.1.3", 52 | "resolved": "https://registry.npm.taobao.org/css-what/download/css-what-2.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcss-what%2Fdownload%2Fcss-what-2.1.3.tgz", 53 | "integrity": "sha1-ptdgRXM2X+dGhsPzEcVlE9iChfI=" 54 | }, 55 | "debug": { 56 | "version": "3.1.0", 57 | "resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz", 58 | "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", 59 | "requires": { 60 | "ms": "2.0.0" 61 | } 62 | }, 63 | "dom-serializer": { 64 | "version": "0.1.1", 65 | "resolved": "https://registry.npm.taobao.org/dom-serializer/download/dom-serializer-0.1.1.tgz", 66 | "integrity": "sha1-HsQFnihLq+027sKUHUqXChic58A=", 67 | "requires": { 68 | "domelementtype": "^1.3.0", 69 | "entities": "^1.1.1" 70 | } 71 | }, 72 | "domelementtype": { 73 | "version": "1.3.1", 74 | "resolved": "https://registry.npm.taobao.org/domelementtype/download/domelementtype-1.3.1.tgz", 75 | "integrity": "sha1-0EjESzew0Qp/Kj1f7j9DM9eQSB8=" 76 | }, 77 | "domhandler": { 78 | "version": "2.4.2", 79 | "resolved": "https://registry.npm.taobao.org/domhandler/download/domhandler-2.4.2.tgz", 80 | "integrity": "sha1-iAUJfpM9ZehVRvcm1g9euItE+AM=", 81 | "requires": { 82 | "domelementtype": "1" 83 | } 84 | }, 85 | "domutils": { 86 | "version": "1.5.1", 87 | "resolved": "https://registry.npm.taobao.org/domutils/download/domutils-1.5.1.tgz", 88 | "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", 89 | "requires": { 90 | "dom-serializer": "0", 91 | "domelementtype": "1" 92 | } 93 | }, 94 | "entities": { 95 | "version": "1.1.2", 96 | "resolved": "https://registry.npm.taobao.org/entities/download/entities-1.1.2.tgz", 97 | "integrity": "sha1-vfpzUplmTfr9NFKe1PhSKidf6lY=" 98 | }, 99 | "follow-redirects": { 100 | "version": "1.5.10", 101 | "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz?cache=0&sync_timestamp=1567775546836&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.5.10.tgz", 102 | "integrity": "sha1-e3qfmuov3/NnhqlP9kPtB/T/Xio=", 103 | "requires": { 104 | "debug": "=3.1.0" 105 | } 106 | }, 107 | "htmlparser2": { 108 | "version": "3.10.1", 109 | "resolved": "https://registry.npm.taobao.org/htmlparser2/download/htmlparser2-3.10.1.tgz", 110 | "integrity": "sha1-vWedw/WYl7ajS7EHSchVu1OpOS8=", 111 | "requires": { 112 | "domelementtype": "^1.3.1", 113 | "domhandler": "^2.3.0", 114 | "domutils": "^1.5.1", 115 | "entities": "^1.1.1", 116 | "inherits": "^2.0.1", 117 | "readable-stream": "^3.1.1" 118 | } 119 | }, 120 | "inherits": { 121 | "version": "2.0.4", 122 | "resolved": "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz", 123 | "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=" 124 | }, 125 | "is-buffer": { 126 | "version": "2.0.4", 127 | "resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-2.0.4.tgz?cache=0&sync_timestamp=1569904999656&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-buffer%2Fdownload%2Fis-buffer-2.0.4.tgz", 128 | "integrity": "sha1-PlcvI8hBGlz9lVfISeNmXgspBiM=" 129 | }, 130 | "lodash": { 131 | "version": "4.17.15", 132 | "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz", 133 | "integrity": "sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=" 134 | }, 135 | "ms": { 136 | "version": "2.0.0", 137 | "resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz", 138 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 139 | }, 140 | "nth-check": { 141 | "version": "1.0.2", 142 | "resolved": "https://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz", 143 | "integrity": "sha1-sr0pXDfj3VijvwcAN2Zjuk2c8Fw=", 144 | "requires": { 145 | "boolbase": "~1.0.0" 146 | } 147 | }, 148 | "parse5": { 149 | "version": "3.0.3", 150 | "resolved": "https://registry.npm.taobao.org/parse5/download/parse5-3.0.3.tgz?cache=0&sync_timestamp=1573036762880&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fparse5%2Fdownload%2Fparse5-3.0.3.tgz", 151 | "integrity": "sha1-BC95L/3TaFFVHPTp4Gazh0q0W1w=", 152 | "requires": { 153 | "@types/node": "*" 154 | } 155 | }, 156 | "readable-stream": { 157 | "version": "3.4.0", 158 | "resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.4.0.tgz", 159 | "integrity": "sha1-pRwmdUZY4KPCHb9ZFjvUW6b0R/w=", 160 | "requires": { 161 | "inherits": "^2.0.3", 162 | "string_decoder": "^1.1.1", 163 | "util-deprecate": "^1.0.1" 164 | } 165 | }, 166 | "safe-buffer": { 167 | "version": "5.2.0", 168 | "resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.0.tgz", 169 | "integrity": "sha1-t02uxJsRSPiMZLaNSbHoFcHy9Rk=" 170 | }, 171 | "string_decoder": { 172 | "version": "1.3.0", 173 | "resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.3.0.tgz", 174 | "integrity": "sha1-QvEUWUpGzxqOMLCoT1bHjD7awh4=", 175 | "requires": { 176 | "safe-buffer": "~5.2.0" 177 | } 178 | }, 179 | "util-deprecate": { 180 | "version": "1.0.2", 181 | "resolved": "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz", 182 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 183 | } 184 | } 185 | } 186 | --------------------------------------------------------------------------------