Editing _.squeeze This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"> </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) var json = { "experience": [{ "position": "Front-end Team Leader", "company": "Media Net Software", "period": { "start": "February 2012", "end": "Present", "duration": "(1 year 1 month)", "location": "Madrid Area, Spain" }, "description": "Currently working on the new portal of BBVA bank. \r\n Writing HTML5, CSS3, SASS, modular JavaScript APIs, Backbone, underscore, jQuery & more." }, { "position": "Web developer", "company": "Ticketea", "period": { "start": "July 2010", "end": "", "duration": "(1 year 7 months)", "location": "Madrid Area, Spain" }, "description": "Building the product from scratch using SCRUM, TDD, LAMP, JavaScript (jQuery), XHTML, CSS, Git. Integrations with affiliates, Google and Facebook APIs." }, { "position": "Web developer", "company": "Comunica+A, The Internet Sales Company", "period": { "start": "May 2009", "end": "", "duration": "(1 year 2 months)", "location": "Madrid Area, Spain" }, "description": "Websites for clients such as Orange, Endesa, MRW, McDonalds, Wilkinson, Alfa Romeo, Lancia, Real Madrid FC, entradas.com, Mutua Madrileña, la Caixa, red.es, AECEM, etc. LAMP, XHTML, CSS, JavaScript." }, { "position": "Web developer", "company": "Arionline s.r.l.", "period": { "start": "2007", "end": "", "duration": "(2 years)", "location": "Cagliari Area, Italy" }, "description": "Software programming, R&D projects, web apps, with Open Source technology." }], "languages": [{ "language": "Italian", "proficiency": "(Native or bilingual proficiency)" }, { "language": "Spanish", "proficiency": "(Native or bilingual proficiency)" }, { "language": "English", "proficiency": "(Limited working proficiency)" }], "skills": ["HTML5", "CSS3", "JavaScript", "PHP", "MySQL", "jQuery", "Backbone.js", "Front-end Development", "Scrum", "Agile", "TDD", "MVC", "OOP", "Database Design", "LAMP", "PHP Frameworks", "Git", "Test Driven Development", "HTML 5", "Front-end"] }; _.mixin({ squeeze: function(obj) { var _extract = function(obj, result) { _.each(obj, function(propValue, propName) { if (propValue) { if (_.isArray(propValue)) { _extract(propValue, result); } else if (_.isObject(propValue)) { _extract(_.flatten(propValue), result); } else if (_.isString(propValue)) { result.push(propValue); } } }) return result; } return _extract(obj, []); }, squeeze2: function (obj) { var extract = function (obj, result) { _.each(obj, function(value, name) { if (value && _.isString(value)) { result.push(value); } else { if (_.isArray(value)) { extract(value, result); } if (_.isObject(value)) { extract(_.flatten(value), result); } } }) return result; } return extract(obj, []); } }); Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code _.squeeze(json); Test 2 Title Async (check if this is an asynchronous test) Code _.squeeze2(json);