Skip to content

Commit

Permalink
Merge pull request #1 from hckrnews/feature/first-draft
Browse files Browse the repository at this point in the history
Add all files
  • Loading branch information
w3nl authored Oct 4, 2021
2 parents ae3598f + d4cf93b commit 3be64e0
Show file tree
Hide file tree
Showing 16 changed files with 19,384 additions and 100 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [w3nl]
patreon: w3news
54 changes: 54 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Code scanning - action"

on:
push:
branches: [main, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '0 4 * * 5'

jobs:
CodeQL-Build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with:
languages: javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint, and test
run: |
npm ci
npm run vulnerabilities
npm run lint
npm test
env:
CI: true
32 changes: 32 additions & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm ci
- run: npm run vulnerabilities
- run: npm run lint
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci --production
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
118 changes: 19 additions & 99 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

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

# Coverage directory used by tools like istanbul
.DS_Store
node_modules
coverage
*.lcov

# nyc test coverage
.nyc_output

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

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist
report

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/
# local env files
.env.local
.env.*.local

# DynamoDB Local files
.dynamodb/
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# TernJS port file
.tern-port
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.dccache
7 changes: 7 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"threshold": 0,
"reporters": ["json", "console"],
"ignore": ["**/__snapshots__/**"],
"absolute": true,
"gitignore": true
}
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sudo: true
dist: trusty
addons:
language: node_js
node_js:
- "12"
- "14"
- "16"
before_script:
- npm run lint
after_script:
- npm run coveralls
git:
depth: 10
cache:
yarn: true
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pieter Wigboldus <[email protected]>
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# enum
# Create vanilla JavaScript enums

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Scrutinizer Code Quality][scrutinizer-image]][scrutinizer-url]

## Installation

`npm install @hckrnews/enum`
or
`yarn add @hckrnews/enum`

## Test the package

`npm run test`
or
`yarn test`

## Usage

```javascript
import Enum from '@hckrnews/enum'

class Ecample extends Enum {
get options () {
return {
'test': 'TEXT'
}
}
}

const encoding = Encoding.fromKey('test')
encoding.key // test
encoding.value // TEXT
encoding.values // [ 'TEXT' ]
encoding.options // { test: 'TEXT' }
encoding.keys // [ 'test' ]
encoding.test // TEXT
encoding.length // 1


const encoding = Encoding.fromValue('TEXT')
encoding.key // test
encoding.value // TEXT

Encoding.hasKey('test') // teue
Encoding.hasKey('TEXT') // false
Encoding.hasValue('test') // teue
Encoding.hasValue('TEXT') // false
```

[npm-url]: https://www.npmjs.com/package/@hckrnews/enum
[npm-image]: https://img.shields.io/npm/v/@hckrnews/enum.svg
[travis-url]: https://app.travis-ci.com/hckrnews/enum
[travis-image]: https://app.travis-ci.com/hckrnews/enum.svg?branch=main
[coveralls-url]: https://coveralls.io/r/hckrnews/enum
[coveralls-image]: https://img.shields.io/coveralls/hckrnews/enum/main.svg
[scrutinizer-url]: https://scrutinizer-ci.com/g/hckrnews/enum/?branch=main
[scrutinizer-image]: https://scrutinizer-ci.com/g/hckrnews/enum/badges/quality-score.png?b=main
13 changes: 13 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
plugins: ['@babel/plugin-transform-modules-commonjs'],
};
20 changes: 20 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
moduleFileExtensions: ['js', 'jsx', 'json'],

transform: {
'^.+\\.js?$': 'babel-jest',
},

transformIgnorePatterns: ['node_modules/(?!(@hckrnews)/)'],

moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},

testMatch: ['**/__tests__/*.js'],

testURL: 'http://localhost/',

collectCoverage: true,
collectCoverageFrom: ['src/**/*.js'],
};
Loading

0 comments on commit 3be64e0

Please sign in to comment.