This file contains 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
struct node_module { | |
int nm_version; | |
unsigned int nm_flags; | |
void* nm_dso_handle; | |
const char* nm_filename; | |
node::addon_register_func nm_register_func; | |
node::addon_context_register_func nm_context_register_func; | |
const char* nm_modname; | |
void* nm_priv; | |
struct node_module* nm_link; |
This file contains 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
void node_module_register(void* m) { | |
struct node_module* mp = reinterpret_cast<struct node_module*>(m); | |
if (mp->nm_flags & NM_F_BUILTIN) { | |
mp->nm_link = modlist_builtin; | |
modlist_builtin = mp; | |
} else if (!node_is_initialized) { | |
// "Linked" modules are included as part of the node project. | |
// Like builtins they are registered *before* node::Init runs. | |
mp->nm_flags = NM_F_LINKED; |
This file contains 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
struct node_module* get_builtin_module(const char* name) { | |
struct node_module* mp; | |
for (mp = modlist_builtin; mp != nullptr; mp = mp->nm_link) { | |
if (strcmp(mp->nm_modname, name) == 0) | |
break; | |
} | |
CHECK(mp == nullptr || (mp->nm_flags & NM_F_BUILTIN) != 0); | |
return (mp); |
This file contains 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
#define NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, priv, flags) \ | |
extern "C" { \ | |
static node::node_module _module = \ | |
{ \ | |
NODE_MODULE_VERSION, \ | |
flags, \ | |
NULL, \ | |
__FILE__, \ | |
NULL, \ | |
(node::addon_context_register_func) (regfunc), \ |
This file contains 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
// Include header files here | |
namespace node { | |
// Using namespaces | |
// Define useful macros | |
// And a lot other stuff here in C++ | |
void UpdateHeapStatisticsArrayBuffer(const FunctionCallbackInfo<Value>& args) { | |
// Some logic here... | |
} | |
void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { |
This file contains 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
void DefineJavaScript(Environment* env, Handle<Object> target) { | |
HandleScope scope(env->isolate()); | |
for (int i = 0; natives[i].name; i++) { | |
if (natives[i].source != node_native) { | |
Local<String> name = String::NewFromUtf8(env->isolate(), natives[i].name); | |
Handle<String> source = String::NewFromUtf8(env->isolate(), natives[i].source, String::kNormalString, natives[i].source_len); | |
target->Set(name, source); | |
} | |
} |
This file contains 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
'use strict'; | |
const CURRENT_YEAR = 2015; | |
// Generator that shifts days by bits | |
function* developersDayGenerator() { | |
let day = 1; | |
while (day < 365) { | |
yield day; | |
day = day << 1; |
This file contains 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
'use strict'; | |
import fs from 'fs'; | |
import program from 'commander'; | |
import Speaker from 'speaker'; | |
import { Decoder } from 'lame'; | |
import Parser from 'icecast-parser'; | |
program | |
.option('-s, --source <source>', 'Source station') |
This file contains 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
const fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
const result = INPUT.reduce((floor, direction) => direction === '(' ? ++floor : --floor, 0); | |
console.log(result); |
This file contains 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
const fs = require('fs'); | |
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split(''); | |
let floor = 0; | |
let result = INPUT.map(direction => direction === '(' ? ++floor : --floor).indexOf(-1) + 1; | |
console.log(result); |
OlderNewer