草庐IT

test_and_set

全部标签

javascript - 加密错误 : data and hash arguments required

我收到一个bcrypt错误,指出需要数据和哈希参数,引用我的routes.js文件中的第44行。据我所知,我正在传递该信息:bcrypt.compare的第一个参数是用户输入的密码,第二个是从数据库中检索到的散列密码。我做错了什么?bcrypt.compare(req.params.password,user.password,function...routes.js'usestrict'varexpress=require('express');varrouter=express.Router();varUser=require('../app/models/user');//pas

javascript - VideoJS : Stopping video on modal close and not embedding in page

我一直在使用JavaScript脚本VideoJS:http://videojs.com/构建一些可以在弹出窗口中显示给用户的视频播放器。我按如下方式构建了弹出窗口:VideoJS.setupAllWhenReady();jQuery(document).ready(function(){//videoshavevideojsappliedtothem//$("video").VideoJS()$(".show-video").click(function(){$(".video-background").show();$(".video-container").fadeIn("fas

javascript - Chrome 扩展 : load and execute external script

我无法将外部js脚本加载到我的chrome扩展中并执行。看起来与thisquestion相同,但我仍然无法弄清楚为什么它在我的情况下不起作用。我的想法是,我想在我的内容脚本中包含一些应该解析网页内容的默认函数。对于一些特定的网页,我想加载和使用特定的解析器,所以我尝试为一个网页加载适当的js脚本,这个脚本应该扩展默认解析器的功能。现在我只尝试从外部脚本执行代码,但有这样的错误:这是我的ma​​nifest.json:{"name":"Extensionname","version":"1.2","description":"Mychromeextension","browser_act

javascript - Jasmine + AngularJS : How to test $rootScope. $broadcast 被调用参数?

我正在尝试编写一个单元测试来验证是否调用了$rootScope.$broadcast('myApiPlay',{action:'play'});。这是myapi.jsangular.module('myApp').factory('MyApi',function($rootScope){varapi={};api.play=function(){$rootScope.$broadcast('myApiPlay',{action:'play'});}returnapi;});这是我的单元测试:describe('Service:MyApi',function(){//loadtheser

javascript - 在 ES6 Set 中存储数组并按值访问它们

是否有一种简单的方法来验证ES6Set包含的值是特定数组?我想要一个不需要我使用引用的解决方案:varset=newSet();vararray=[1,2];set.add(array);set.has(array);//trueset.add([3,4]);set.has([3,4]);//false到目前为止,我的解决方案是将所有内容存储为字符串,但这很烦人:set.add([3,4].toString());set.has([3,4].toString());//true 最佳答案 不,没有。Set适用于对象和基元,对于防止相

javascript - webpackJsonp 未定义 : webpack-dev-server and CommonsChunkPlugin

这是我的webpack.config.js文件:constwebpack=require('webpack');constpath=require('path');module.exports={cache:true,devtool:'source-map',entry:{app:['./src/index.js'],vendor:['lodash']},output:{filename:'bundle.js',path:path.join(__dirname,'dist'),publicPath:'/dist/',pathinfo:true},module:{loaders:[{te

javascript - 谷歌地图 API v3 : computeDistanceBetween method and distance in metric form

我想以公制形式计算位置之间的直接距离。(即:从A到B,以公里为单位)。没看懂computeDistanceBetween方法以单位返回。谢谢 最佳答案 以米为单位。要转换为公里除以10241000,obviously.google.maps.geometry.spherical.computeDistanceBetween(Moscow,Leningrad);//679601m对了,这个库方法的底层代码是基于Haversineformula的. 关于javascript-谷歌地图APIv

javascript - 从 AJAX POST 响应获取和存储 cookie(来自 Set-Cookie)

我有一个简单的jQueryAJAXPOST代码:$.ajax({type:"POST",url:AppConstants.URLs.PROXY,data:message,xhrFields:{withCredentials:true},success:function(data,status,xhr){console.log("Cookie:"+xhr.getResponseHeader("Set-Cookie"));}});我希望获取cookie并使用cookies-js保存它.但根据http://www.w3.org/TR/XMLHttpRequest/#the-getallres

javascript - 如何可靠地检查对象是 EcmaScript 6 Map/Set?

我只想检查一个对象是Map还是Set而不是Array。我使用lodash的_.isArray检查数组。functionmyFunc(arg){if(_.isArray(arg)){//doSomethingWithArray(arg)}if(isMap(arg)){//doSomethingWithMap(arg)}if(isSet(arg)){//doSomethingWithSet(arg)}}如果我要实现isMap/isSet,它需要看起来像什么?如果可能的话,我希望它能够捕获Map/Set的子类。 最佳答案 这种情况类似于正

javascript - 初级 JavaScript : Working with JSON and Objects in JavaScript

我有一些像这个“产品”一样返回给浏览器的JSON:{"Title":"SchoolBag","Image":"/images/school-bag.jpg"}我希望此数据成为“产品”对象,因此我可以使用原型(prototype)方法,如返回产品的HTML图像表示的toHTMLImage():functionProduct(){}Product.prototype.toHTMLImage=function(){//Returnssomethinglike"alt=""/>}如何将我的JSON结果转换为Product对象,以便我可以使用toHTMLImage?