Skip to content

Instantly share code, notes, and snippets.

var UrlSearch = require("./url-search");
describe("objectizeUrlSearch", function () {
it("should convert search string to search object", function() {
var
urlSearch = "a=1&a=2&b=3",
searchObject = {
"a": ["1","2"],
"b": "3"
};
expect(UrlSearch.objectizeUrlSearch(urlSearch))
{
a: ["1","2"],
b: "3"
}
@fonzerelly
fonzerelly / get_partialRight_right_02.js
Last active September 2, 2016 22:17
caveat of _.partialRight
_.map(books, getNumberOfPages);
// undefined, undefined, undefined
@fonzerelly
fonzerelly / get_partialRight_right_03.js
Last active September 2, 2016 22:15
reason of missbehaviour
//expected call for book[0]:
_.result(books[0], "numberOfPages");
//evaluated call:
_.result(books[0], 0, books, "numberOfPages");
//which means effectivly
_.result(books[0], 0);
@fonzerelly
fonzerelly / jasmine_on_rhino_03
Created January 19, 2014 23:21
Rhino based SpecRunner for jasmine
//Imported by Rhino on command shell
/*global load, print*/
load("lib/Timer.js");
/*global endAllTimers*/
load("lib/TextReporter.js");
/*global TextReporter*/
load("lib/jasmine-1.3.0/jasmine.js");
/*global jasmine*/
TextReporter.prototype = new jasmine.Reporter();
TextReporter.prototype.onRunnerFinished = function (callback) {
this.callbackEnd = callback;
};
TextReporter.prototype.reportRunnerResults = function (runner) {
// When all the spec are finished //
var result = runner.results();
var setTimeout,
clearTimeout,
setInterval,
clearInterval,
endAllTimers;
(function () {
var timer = new java.util.Timer();
var counter = 1;
var ids = {};
@fonzerelly
fonzerelly / get_partialRight_right_04.js
Last active December 30, 2015 08:19
solution: a closure, that cuts of all surplus parameters
_.mixin(
{
"preserveCallersFirstNParams" : function (func, n) {
n = n || 0;
return function () {
return func.apply(this, Array.prototype.slice.call(arguments, 0, n));
};
}
);
@fonzerelly
fonzerelly / get_partialRight_right_01.js
Last active December 30, 2015 07:29
simple example of _.partialRight
var books = [
{
name: "Little Miss Sunshine",
numberOfPages: 32
},
{
name: "Mr. Strong",
numberOfPages: 36
},
{
var myJLayoutWrapper = _createJLayoutWrapper(
trivialHandlePosition,
precalcuatedPredicate,
_.noop //not interessted in putting in a valid size
);