require

Two gems share same require?

旧街凉风 提交于 2019-12-06 01:42:08
问题 When I call: require 'retryable' These two gems clash: https://github.com/robertsosinski/retryable https://github.com/carlo/retryable as they both have a 'retryable' file they ask the user to require. I'm interested in using the first gem, however this doesn't always happen. This code is executed as a part of my own gem, and it has to be reliable across all users. Is there a way to require specifically from a gem (as the gem names are different of course)? How do I resolve this naming

NodeJS require('..')?

白昼怎懂夜的黑 提交于 2019-12-06 01:18:43
I've been looking through some NodeJS examples and I've encountered the following: var module = require('..'); var module = require('../'); I understand what require does, but I don't understand what it does when it's written like this. Can somebody explain it to me please? This is the rule defined in https://nodejs.org/api/modules.html require(X) from module at path Y If X begins with './' or '/' or '../' a. LOAD_AS_FILE(Y + X) b. LOAD_AS_DIRECTORY(Y + X) Since ../ or .. is not a file, it will go to path B, to load as directory LOAD_AS_DIRECTORY(X) If X/package.json is a file, a. Parse X

Dojo1.6新特性:AMD规范

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 00:57:55
1. AMD的由来 前端技术虽然在不断发展之中,却一直没有质的飞跃。除了已有的各大著名框架,比如Dojo,JQuery,ExtJs等等,很多公司也都有着自己的 前端开发框架。这些框架的使用效率以及开发质量在很大程度上都取决于开发者对其的熟悉程度,以及对JavaScript的熟悉程度,这也是为什么很多公司 的技术带头人都喜欢开发一个自己的框架。开发一个自己会用的框架并不难,但开发一个大家都喜欢的框架却很难。从一个框架迁移到一个新的框架,开发者很有可 能还会按照原有框架的思维去思考和解决问题。这其中的一个重要原因就是JavaScript本身的灵活性:框架没办法绝对的约束你的行为,一件事情总可以 用多种途径去实现,所以我们只能在方法学上去引导正确的实施方法。庆幸的是,在这个层面上的软件方法学研究,一直有人在去不断的尝试和改 进,CommonJS就是其中的一个重要组织。他们提出了许多新的JavaScript架构方案和标准,希望能为前端开发提供银蛋,提供统一的指引。 AMD规范 就 是其中比较著名一个,全称是Asynchronous Module Definition,即异步模块加载机制。从它的规范描述页面看,AMD很短也很简单,但它却完整描述了模块的定义,依赖关系,引用关系以及加载机制。 从它被requireJS,NodeJs,Dojo,JQuery使用也可以看出它具有很大的价值,没错

Webpack浅析

纵然是瞬间 提交于 2019-12-06 00:30:56
前言 随着前端技术的飞速发展,前端开发也从静态页面发展到了web应用,简单的静态页面已经不能满足前端开发的需求。这时涌现了大量的工程化工具,例如早期的gulp,grunt等任务流工具,他们类似于使用javascript完成了shell的一些功能。这些工具虽然解决了大量静态文件的批处理问题,但本质上还是对静态文件的操作。 而webpack的出现将前端工程化提升到了一个新的高度,它可谓是将前端的模块化功能发挥到了极致,进而也成为了目前前端市场最火爆的打包工具。在这篇文章里,我们会简单了解一下webpack的打包原理以及进行一些简单的配置。相信看完成篇文章后,您一定会对webpack有着更深的了解。 Webpack打包文件分析 webpack是一个现代javascript模块打包器,由于commonJS提出了js的模块化规范,webpack很好的利用了这一规范。奉行一切文件皆模块的原则,会依据入口文件递归的编译并打包所有依赖到的文件,并将这些文件打包成一个或多个bundle。 您也许会想webpack到底把文件打包成了什么?在实际工作中我们并不需要去关心这个问题,因为webpack已经帮我们做好了一切,并且webpack打包后的代码非常难以阅读。其实打包后的代码看起来复杂,但原理都是一样的,接下来通过一个最基础的小例子来分析一个webpack是如何打包我们的源文件的。

PHP Phar - file_exists() issue

前提是你 提交于 2019-12-05 23:41:23
问题 My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. 回答1: At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply

Handling dependencies not installed with npm, in Mocha?

泄露秘密 提交于 2019-12-05 22:15:26
I have a working Node application and I'm trying to add Mocha tests, but getting some odd import errors. This is my file structure: package.json index.js src/ chart.js test/ test_chart.js This is what my chart.js file looks like: global.jQuery = require('jquery'); global.$ = global.jQuery; require('typeahead'); require('bloodhound'); var bootstrap = require('bootstrap'); var Handlebars = require('handlebars'); var Highcharts = require('highcharts-browserify'); var parse = require('csv-parse'); var moment = require('moment'); var analyseChart = { doSomething: function() { ... } }; module

Vue动态加载图片图片不显示

自闭症网瘾萝莉.ら 提交于 2019-12-05 20:44:17
图片是放在assets文件夹下的 使用require进行解决 图片不显示的原因 在webpack,将图片放在assets中,会将图片图片来当做模块来用,因为是动态加载的,所以url-loader将无法解析图片地址, <el-table-column label="照片"> <template slot-scope="scope"> <i class="el-icon-picture-outline" @click="showPhoto(scope.row)"></i> <img id="aa" :src="scope.row.img" /> </template> </el-table-column> { date: "2016-05-02", studentId: "201319981010", name: "王2虎", className: "高2018级2班", img: require("../../../assets/image/wearther.png"), //引号中括号里面哦 address: "区金沙江路 1518 弄" }, 来源: https://www.cnblogs.com/IwishIcould/p/11946283.html

axis2 client namespace mismatch

血红的双手。 提交于 2019-12-05 19:32:57
在基于axis2进行WebService开发部署时(使用Java客户端调用服务)可能会报namespace mismatch require http://ws.apache.org/axis2 found http://ws.apache.org/axis2/xsd 这样的错误.根据本人的经验,当使用POJO这种方式开发时,Qname中的参数为http://ws.apache.org/axis2,在基于service.xml开发时其参数为http://service. 当然当命名空间报错时在Java开发环境下,可以从调试窗口发现类似的信息:Exception in thread "main" org.apache.axis2.AxisFault: namespace mismatch require http://service foundhttp://ws.apache.org/axis2 .将命名空间改为require后面的即可。 如下我的报错 Exception in thread "main" org.apache.axis2.AxisFault: namespace mismatch require http://fileserver.sdfr.com found http://service 我服务端发布的服务应该是红色报名,但是我的代码中用的是蓝色部分,所以报错

【前端知识体系-NodeJS相关】NodeJS高频前端面试题整理

≯℡__Kan透↙ 提交于 2019-12-05 18:07:25
1. 为什么JavaScript是单线程? 防止DOM渲染冲突的问题; Html5中的Web Worker可以实现多线程 2.什么是任务队列? 任务队列"是一个先进先出的数据结构,排在前面的事件,优先被主线程读取。主线程的读取过程基本上是自动的,只要执行栈一清空,"任务队列"上第一位的事件就自动进入主线程。 2.1 同步和异步任务 同步任务指的是,在主线程上排队执行的任务,只有前一个任务执行完毕,才能执行后一个任务; 异步任务指的是,不进入主线程、而进入"任务队列"(task queue)的任务,只有"任务队列"通知主线程,某个异步任务可以执行了,该任务才会进入主线程执行。 2.2 执行流程 所有同步任务都在主线程上执行,形成一个执行栈(execution context stack)。 主线程之外,还存在一个"任务队列"(task queue)。只要异步任务有了运行结果,就在"任务队列"之中放置一个事件。 一旦"执行栈"中的所有同步任务执行完毕,系统就会读取"任务队列",看看里面有哪些事件。那些对应的异步任务,于是结束等待状态,进入执行栈,开始执行。 主线程不断重复上面的第三步。 3. 什么是事件循环(EventLoop)? 主线程从"任务队列"中读取事件,这个过程是循环不断的,所以整个的这种运行机制又称为Event Loop(事件循环)。 3.1 定时器函数的基本使用方法对比?

Babel transpiles 'import' to 'require', but 'require isn't useable in ecma5

烈酒焚心 提交于 2019-12-05 18:02:17
问题 It was my understanding that use Babel allows you to use ecma6 javascript in an ecma5 environment by transpiling. When I use 'import' however, the 'import' is transpilied to 'require'. 'require' isn't ecma5 and requires the library 'require.js'. Therefore you can't use 'import/ export' without additional dependencies, is this correct? 回答1: Yes, Babel is just intended for translating new language features to be compatible with modern javascript engines. Babel doesn't compile to require.js