This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var async = require('async'); | |
| var arr = [1,2,3,4]; | |
| async.each(arr,function(item, cb){ | |
| setTimeout(function() { | |
| console.log('#1: ', item); | |
| return cb(); | |
| }, Math.random()*2000); | |
| }, function(err){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var async = require('async'); | |
| var arr = [1,2,3,4]; | |
| async.eachSeries(arr,function(item, cb){ | |
| setTimeout(function() { | |
| console.log('#1: ', item); | |
| return cb(); | |
| }, Math.random()*2000); | |
| }, function(err){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var obj = { | |
| one: 'one', | |
| two: 'two' | |
| }; | |
| // Forgot to add length after Object.keys(obj) | |
| var isBig = Object.keys(obj) > 1; | |
| console.log(isBig); | |
| // false but should be true. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I create a script to generate this groovy - i.e. did not write it by hand | |
| mgmt = graph.openManagement(); | |
| if(!mgmt.containsPropertyKey('TEXT_key_prop')){ | |
| k = mgmt.makePropertyKey('TEXT_key_prop').dataType(String.class).cardinality(Cardinality.SINGLE).make(); | |
| mgmt.buildIndex('TEXT_index_name', Vertex.class).addKey(k, Mapping.TEXT.asParameter()).buildMixedIndex('search'); | |
| mgmt.commit(); | |
| graph.addVertex('TEXT_key_prop', 'The quick brown fox JUMPS oVeR the lazy dog'); | |
| graph.tx().commit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // After resetting the Master Combo Lock I was unable to unlock it. | |
| // Assuming that I had been off on one or more on the new number/ | |
| // letters I needed to generate all of the combinations so I could | |
| // open it. | |
| // This is an example of the combo I thought I set it to: | |
| const combo = '0AT'; | |
| // These are the numbers/letters available on the dial: | |
| const letters = '0123456789ADEHJLNRST'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Which is faster depends on which version of Node you're using. | |
| // See the bottom for the results. | |
| const iterations = 1000000; | |
| const arrayOfTen = [...Array(10).keys()]; | |
| const arrayOfArrays = [...Array(10).keys()].map(() => arrayOfTen); | |
| const NS_PER_SEC = 1e9; | |
| function a() { | |
| for (let i = 1; i < iterations; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I was not expecting this. I changed a test using Node's assert.deepEqual() to | |
| // Jest's toEqual(). | |
| // Node's deepEqual(): | |
| assert.deepEqual(transformed, plant); | |
| // passed! | |
| // Jest's toEqual(): | |
| expect(transformed).toEqual(plant); | |
| // Fails: |
OlderNewer