Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Desmarais authored and terodox committed Jan 17, 2019
0 parents commit e4bc0ef
Show file tree
Hide file tree
Showing 18 changed files with 9,445 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"presets": [
[
"env",
{
"targets": {
"browsers": [
">0.25%",
"ie>=10",
"not op_mini all"
]
}
}
]
]
}
49 changes: 49 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# temporary workaround for this bug:
# https://github.com/drone/drone/issues/2390
clone:
git:
image: plugins/git:next
pull: true
#
# end workaround
#

pipeline:
install:
image: node:10
commands:
- echo "//registry.npmjs.org/:_authToken=$${NPM_INSTALL_TOKEN}" > ~/.npmrc
- npm install
secrets:
- npm_install_token
test:
image: meltwaterlegion/node-headless-chrome
commands:
- echo "//registry.npmjs.org/:_authToken=$${NPM_INSTALL_TOKEN}" > ~/.npmrc
- npm test
secrets:
- npm_install_token
build:
image: node:10
commands:
- echo "//registry.npmjs.org/:_authToken=$${NPM_INSTALL_TOKEN}" > ~/.npmrc
- npm run build
secrets:
- npm_install_token
when:
event: tag
deploy:
image: node:10
commands:
- echo "//registry.npmjs.org/:_authToken=$${NPM_DEPLOY_TOKEN}" > ~/.npmrc
- echo "unsafe-perm=true" >> ~/.npmrc
- npm publish
environment:
- BUILD_ENV=production
secrets:
- npm_deploy_token
when:
event: tag
branch:
- include: [ v* ]
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.spec.js
*.config.js
121 changes: 121 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
// http://eslint.org/docs/rules/
"env": {
"browser": true,
"amd": true,
"jasmine": true,
"es6": true,
"node": true
},
"globals": {
"angular": true
},
"parserOptions": {
"sourceType": "module"
},

"extends": "eslint:recommended",
"rules": {
"valid-jsdoc": "error",
"default-case": "error",
"no-alert": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": [
"error",
{
"ignore": [0, 1, 2]
}
],
"no-param-reassign": "error",
"no-return-assign": ["error", "always"],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"no-void": "error",
"no-with": "error",

/**
* Stylistic rules
*/

"camelcase": "error",
"complexity": "error",
"curly": [
"error",
"all"
],
"indent": [
"error",
4, // http://eslint.org/docs/rules/indent
{
"SwitchCase": 1
}
],
"max-depth": [
"error",
3 // http://eslint.org/docs/rules/max-depth
],
"new-cap": "error",
"new-parens": "error",
"no-continue": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-nested-ternary": "error",
"no-tabs": "error",
"no-trailing-spaces": [
"error",
{
"ignoreComments": true,
"skipBlankLines": true
}
],
"no-unneeded-ternary": "error",
"nonblock-statement-body-position": [
"error",
"beside" // http://eslint.org/docs/rules/nonblock-statement-body-position
],
"one-var-declaration-per-line": [
"error",
"always"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"vars-on-top": "error",

/**
* ES6 Specific
*/

"arrow-body-style": [
"error",
"as-needed"
],
"no-confusing-arrow": "error",
"no-useless-constructor": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error"
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/
.vscode/
coverage/
dist/
node_modules/
cjs/

.DS_Store
npm-debug.log*
20 changes: 20 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.idea/
coverage/
docs/
node_modules/
src/
scripts/

.DS_Store
npm-debug.log*
.spec.js

.drone.yml
CONTRIBUTING.md
PULL_REQUEST_TEMPLATE.md
webpack*
karma.config.js
jasmine.json
.nvmrc
.babelrc
.eslint*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v10.10
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Policy
We will accept contributions of good code that we can use from anyone.

## What this means

### “We will accept”
This means that we will incorporate your contribution into the project’s codebase, adapt it as needed, and give you full credit for your work.

### “contributions”
This means just about anything you wish to contribute to the project, as long as it is good code we can use. The easier you make it for us to accept your contribution, the happier we are, but if it’s good enough, we will do a reasonable amount of work to use it.

### “of good code”
This means that we will accept contributions that work well and efficiently, that fit in with the goals of the project, that match the project’s coding style, and that do not impose an undue maintenance workload on us going forward. This does not mean just program code, either, but documentation and artistic works as appropriate to the project.

### “that we can use”
This means that your contribution must be given freely and irrevocably, that you must have the right to contribute it for our unrestricted use, and that your contribution is made under a license that is compatible with the license the project has chosen and that permits us to include, distribute, and modify your work without restriction.

### “from anyone”
This means exactly that. We don’t care about anything but your code. We don’t care about your race, religion, national origin, biological gender, perceived gender, sexual orientation, lifestyle, political viewpoint, or anything extraneous like that. We will neither reject your contribution nor grant it preferential treatment on any basis except the code itself. We do, however, reserve the right to tell you to go away if you behave too obnoxiously toward us.

## If Your Contribution Is Rejected
If we reject your contribution, it means only that we do not consider it suitable for our project in the form it was submitted. It is not personal. If you ask civilly, we will be happy to discuss it with you and help you understand why it was rejected, and if possible improve it so we can accept it. If we are not able to reach an agreement, then you are free to fork our project, as with any Open Source project, and add your contribution to your fork.

###### *This text was pulled verbatim from a [wonderful post](https://medium.com/@jmaynard/a-contribution-policy-for-open-source-that-works-bfc4600c9d83) by [Jay Maynard](https://medium.com/@jmaynard?source=post_header_lockup)*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Meltwater

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* [ ] Change is tested locally
* [ ] Demo is updated to exercise change (if applicable)
* [ ] [WIP] flag is removed from the title
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# @meltwater/coerce

A simple javascript package for type checking an object

# Install

```bash
npm i --save @meltwater/coerce
```

# API reference

Please see [full api documentation here](docs/API.md)

# Usage

```javascript
class ValidatedObject {
constructor({ value }) {
if(typeof value !== string) {
throw new TypeError(`options.value must be a string. Provided value: ${value}`);
}

this.value = value;
Object.freeze(this);
}
}

const badValue = { value: 1234 };
coerce(badValue, ValidatedObject, 'Booooooom!');
// This will throw a TypeError with the message 'Booooooom!'

const goodValue = { value: 'so good' };
const typedValue = coerce(goodValue, ValidatedObject, 'Booooooom');
// This will return a new object that is an instanceof ValidatedObject with typedValue.value === 'so good'
```
29 changes: 29 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [coerce][1]
- [Parameters][2]

## coerce

Validate an object is an instance of the expected type, or is a valid constructor object for the requested type

### Parameters

- `value` **any** The value for validation
- `Type` **any** The type for instance of comparison
- `message` **[string][3]** The message to be displayed if coercion fails


- Throws **[TypeError][4]** If the value is not coercable.

Returns **any** Instance of provided Type

[1]: #coerce

[2]: #parameters

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypeError
26 changes: 26 additions & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Architecture Decision Records
ADRs are the preemptive answers to future contributors asking "why did they implement it this way?"

It's impossible to predict what those questions will be, but, roughly speaking, decisions are worth documenting if:
* it *required* a whiteboard to reach consensus among the initial contributors
* it has needed to be revisited since it was initially decided

## Format
The format below is based on [a blog post](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions) by Michael Nygard.

### Title
A short noun phrase.

For example, "ADR 1: Deployment on Ruby on Rails 3.0.10" or "ADR 9: LDAP for Multitenant Integration"

### Context
This section describes the forces at play, including technological, political, social, and project local. These forces are probably in tension, and should be called out as such. The language in this section is value-neutral. It is simply describing facts.

### Decision
This section describes our response to these forces. It is stated in full sentences, with active voice. "We will ..."

### Status
A decision may be "proposed" if the project stakeholders haven't agreed with it yet, or "accepted" once it is agreed. If a later ADR changes or reverses a decision, it may be marked as "deprecated" or "superseded" with a reference to its replacement.

### Consequences
This section describes the resulting context, after applying the decision. All consequences should be listed here, not just the "positive" ones. A particular decision may have positive, negative, and neutral consequences, but all of them affect the team and project in the future.
6 changes: 6 additions & 0 deletions jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"spec_dir": "./cjs",
"spec_files": [
"**/*.spec.js"
]
}
Loading

0 comments on commit e4bc0ef

Please sign in to comment.