Tag: javascript
-
Hide Sensitive Data with Application Insights JavaScript SDK using a Telemetry Initializer
Application Insights is incredibly powerful, especially when using the JavaScript Client SDK. The problem is, sometimes we can be logging a little too much. We can use a Telemetry Initalizer to hide sensitive data in dependencies / requests logged with Application Insights.
-
How to assert.throws on an async function with a callback
Recently, I was writing a module that took a callback, and needed to write a test, asserting on an exception. Here’s how to do it: it(‘throws error if myParam is less than 10’, function(done) { var fn = function(){ myModule.doSomething(8, function(err) { if (err) throw err }); } assert.throws( function() { fn() }, /Value is…
-
Using custom options with KnockoutJS Drag and Drop
I was recently doing some work involving Knockout and needed to implement drag / drop (with jQuery UI draggable and droppable) I stumbled across this post from Wilsonhut that shows how to use custom binding to attach drag and drop functionality to your view model. Since that post (and previous posts in the series) covers that in…
-
Syntax error using Yahoo YUI Compressor .net port – works using java version
Recently, I was tasked with creating a minified version of a web applications Javascript files. I settled on the Yahoo YUI Compressor, in particular, the .net port of it When I tried to compress a particular file (the jquery.caret plugin), it would throw up a syntax error. This error only occurred using the .net port…
-
Equivalent of LINQ projection / select with Javascript
Not strictly an ‘equivilent’ but a way of achieving the same. For example, consider the following array: var products = [{ id: 1, name: “Product One”}, { id: 2, name: “Product Two”}, { id: 5, name: “Another Product”} ]; Say, for example, we just wanted a list of IDs from this array. With .net, using…