Skip to content

Commit

Permalink
init: project init
Browse files Browse the repository at this point in the history
  • Loading branch information
libterty committed Jul 30, 2021
0 parents commit 7023814
Show file tree
Hide file tree
Showing 16 changed files with 6,494 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'prettier/@typescript-eslint'],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
};
77 changes: 77 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Auto detect
* text=auto

##### Linux
*.sh text eol=lf
*.so binary

# Script
*.bash text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.sh text eol=lf

# Front-end file
*.css text
*.htm text diff=html
*.html text diff=html

# Json Format
*.json text

# Typescript/Javascirpt
*.js text
*.ts text

# C/C++
*.c text
*.cc text
*.cxx text
*.cpp text
*.c++ text
*.hpp text
*.h text
*.h++ text
*.hh text
*.slo binary
*.lo binary
*.o binary
*.obj binary
*.gch binary
*.pch binary
*.so binary
*.dylib binary
*.dll binary
*.lai binary
*.la binary
*.a binary
*.lib binary
*.exe binary
*.out binary
*.app binary

# Docker
*.dockerignore text
Dockerfile text

# Documentation
*.md text
license text
LICENSE text
*README* text

# Linters
.eslintrc.js text

# Configs
*.cnf text
*.conf text
*.config text
.editorconfig text
.env text
.gitattributes text
.gitconfig text
.prettierrc text
*.yaml text
*.yml text
Makefile text
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Mac files
.DS_Store

# Data
sample/

# Test
test.js

# Environment
*.env
*.*.env

# build file
dist/
build/

# IDE
.vscode/
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
src/
.env
.eslintrc.js
.prettierrc
tsconfig.json
.nodemon.json
test/
reports/
.editorconfig
.gitattributes
scripts/
docs/
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 1000,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
7 changes: 7 additions & 0 deletions addons/greeting.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include <string>
#include "greeting.h"

std::string helloWorld(std:: string name) {
return "Hello" + name + "World!";
}
2 changes: 2 additions & 0 deletions addons/greeting.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <string>
std::string helloWorld( std::string name );
43 changes: 43 additions & 0 deletions addons/heap-info/heapInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef HEAPINFO_H
#define HEAPINFO_H

#include <iostream>
#include <napi.h>



#ifdef __APPLE__
#include <unordered_map>
#define unordered_map std::unordered_map
#endif

using namespace std;

namespace hif
{
class HEAP {
public:
struct HeapInfo
{
size_t totalHeapSize;
size_t totalHeapExecutableSize;
size_t totalPhysicalSize;
size_t usedHeapSize;
size_t heapSizeLimit;
size_t totalAvailableSize;
size_t mallocedMemory;
size_t peakMallocedMemory;
size_t numberOfNativeContexts;
size_t numberOfDetachedContexts;
};

struct HeapData
{
HeapInfo* before;
HeapInfo* after;
uint64_t gcStartTime;
uint64_t gcEndTime;
int gctype;
};
}
}
22 changes: 22 additions & 0 deletions addons/index.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <napi.h>
#include <string>
#include "greeting.h"

Napi::String greet(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();

std::string result = helloWorld("lib");

return Napi::String::New(env, result);
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set(
Napi::String::New(env, "greet"),
Napi::Function::New(env, greet)
);

return exports;
}

NODE_API_MODULE(dijkstra, Init)
42 changes: 42 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"targets": [
{
"target_name": "dijkstra",
"include_dirs" : [
"addons",
"<!@(node -p \"require('node-addon-api').include\")"
],
"sources": [
"./addons/greeting.cpp",
"./addons/index.cpp"
],
"cflags" : [
"-std=c++11"
],
"cflags!" : [
"-fno-exceptions"
],
"cflags_cc!": [
"-fno-rtti",
"-fno-exceptions"
],
"ldflags" : [
"-Wl,-rpath,'$$ORIGIN'"
],
"xcode_settings": {
"OTHER_CFLAGS": [
"-std=c++11",
"-stdlib=libc++"
],
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"MACOSX_DEPLOYMENT_TARGET": "10.9"
},
"configurations": {
"Debug": {
"cflags": ["--coverage"],
"ldflags": ["--coverage"]
},
}
}
]
}
9 changes: 9 additions & 0 deletions binding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var module;

if (process.env.DEBUG) {
module = require('./build/Debug/module.node');
} else {
module = require('./build/Release/module.node');
}

module.exports = module;
Loading

0 comments on commit 7023814

Please sign in to comment.