Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
add badges
Browse files Browse the repository at this point in the history
  • Loading branch information
totorogendut committed Mar 25, 2020
1 parent f590854 commit 5e9c09b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 65 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A simple but powerful library to manage monetization on the web.

![Build](https://github.com/ProgNovel/fundme/workflows/Build/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/ProgNovel/fundme/badge.svg?branch=master)](https://coveralls.io/github/ProgNovel/fundme?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/ProgNovel/fundme/badge.svg?branch=master)](https://coveralls.io/github/ProgNovel/fundme?branch=master) ![GitHub top language](https://img.shields.io/github/languages/top/prognovel/fundme) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/fundme) ![npm](https://img.shields.io/npm/v/fundme) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/fundme)

## Dig in (WIP - still hasn't published yet)

Expand Down
29 changes: 13 additions & 16 deletions dist/fundme-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ define(['exports'], function (exports) { 'use strict';
return wmAddress;
}
function getPoolWeightSum(pointers) {
const weights = pointers.map(pointer => pointer.weight);
return Object.values(weights)
.reduce((sum, weight) => sum + weight, 0);
const weights = pointers.map((pointer) => pointer.weight);
return Object.values(weights).reduce((sum, weight) => sum + weight, 0);
}
function getWinningPointer(pointers, choice) {
for (const pointer in pointers) {
Expand All @@ -43,8 +42,8 @@ define(['exports'], function (exports) { 'use strict';

const defaultAddressNotFound = 'Fundme.js: default address not found. Use setDefaultAddress(str: string) to set it first.';
const invalidAddress = 'Fundme.js: Invalid Web Monetization pointer address is given.';
const addressNotFound = "Fundme.js: address not found.";
const addressIsNotAString = "Fundme.js: address must be a string.";
const addressNotFound = 'Fundme.js: address not found.';
const addressIsNotAString = 'Fundme.js: address must be a string.';
function weightIsNotANumber(str) {
return `Fundme.js: ${str} has weight that is not a number. It has been set to ${DEFAULT_WEIGHT} (default).`;
}
Expand All @@ -53,7 +52,7 @@ define(['exports'], function (exports) { 'use strict';
const failParsingTemplate = 'Fundme.js: fails to parse address from <template data-fund></template>.';
// script json template
const cannotParseScriptJson = 'Fundme.js: cannot parse JSON from <script fundme>. Make sure it contains a valid JSON.';
const jsonTemplateIsNotArray = 'Fundme.js: found <script fundme> but it\'s not an array.';
const jsonTemplateIsNotArray = "Fundme.js: found <script fundme> but it's not an array.";

const DEFAULT_WEIGHT = 5;
// TODO check pointer.address with RegEx
Expand All @@ -73,9 +72,9 @@ define(['exports'], function (exports) { 'use strict';
return address;
}
function createPool(pointers) {
return pointers.map(pointer => {
return pointers.map((pointer) => {
let wmPointer;
if (typeof pointer === "string")
if (typeof pointer === 'string')
pointer = convertToPointer(pointer);
if (!('address' in pointer))
throw new Error(addressNotFound);
Expand Down Expand Up @@ -103,7 +102,7 @@ define(['exports'], function (exports) { 'use strict';
function convertToPointer(str) {
const pointer = {
address: str,
weight: DEFAULT_WEIGHT
weight: DEFAULT_WEIGHT,
};
return pointer;
}
Expand Down Expand Up @@ -131,7 +130,7 @@ define(['exports'], function (exports) { 'use strict';
const scriptTags = document.body.querySelectorAll(FUNDME_JSON_SELECTOR);
let pointers = [];
if (scriptTags.length > 0) {
scriptTags.forEach(json => {
scriptTags.forEach((json) => {
pointers = parseScriptJson(json);
});
}
Expand All @@ -157,7 +156,7 @@ define(['exports'], function (exports) { 'use strict';
const templates = document.body.querySelectorAll(FUNDME_TEMPLATE_SELECTOR);
let pointers = [];
if (templates.length > 0) {
templates.forEach(template => {
templates.forEach((template) => {
const pointer = parseTemplate(template);
pointers = [...pointers, pointer];
});
Expand All @@ -166,15 +165,13 @@ define(['exports'], function (exports) { 'use strict';
}
function parseTemplate(template) {
let address = template.dataset.fund;
let weight = template.dataset.fundWeight !== undefined
? parseInt(template.dataset.fundWeight, 0)
: DEFAULT_WEIGHT;
let weight = template.dataset.fundWeight !== undefined ? parseInt(template.dataset.fundWeight, 0) : DEFAULT_WEIGHT;
if (!address) {
throw new Error(failParsingTemplate);
}
const pointer = checkWeight({
address,
weight
weight,
});
return pointer;
}
Expand All @@ -191,7 +188,7 @@ define(['exports'], function (exports) { 'use strict';
})(FundType || (FundType = {}));
function fund(pointer, options) {
// const setDefault = options && options.default
if (typeof pointer === "string") {
if (typeof pointer === 'string') {
if (pointer === 'default') {
if (defaultAddress !== undefined) {
if (typeof defaultAddress === 'string') {
Expand Down
29 changes: 13 additions & 16 deletions dist/fundme-cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ function createWebMonetizationTag(address) {
return wmAddress;
}
function getPoolWeightSum(pointers) {
const weights = pointers.map(pointer => pointer.weight);
return Object.values(weights)
.reduce((sum, weight) => sum + weight, 0);
const weights = pointers.map((pointer) => pointer.weight);
return Object.values(weights).reduce((sum, weight) => sum + weight, 0);
}
function getWinningPointer(pointers, choice) {
for (const pointer in pointers) {
Expand All @@ -45,8 +44,8 @@ function setPointerSingle(pointer) {

const defaultAddressNotFound = 'Fundme.js: default address not found. Use setDefaultAddress(str: string) to set it first.';
const invalidAddress = 'Fundme.js: Invalid Web Monetization pointer address is given.';
const addressNotFound = "Fundme.js: address not found.";
const addressIsNotAString = "Fundme.js: address must be a string.";
const addressNotFound = 'Fundme.js: address not found.';
const addressIsNotAString = 'Fundme.js: address must be a string.';
function weightIsNotANumber(str) {
return `Fundme.js: ${str} has weight that is not a number. It has been set to ${DEFAULT_WEIGHT} (default).`;
}
Expand All @@ -55,7 +54,7 @@ const noTemplateFound = 'Fundme.js: no monetization template is found.';
const failParsingTemplate = 'Fundme.js: fails to parse address from <template data-fund></template>.';
// script json template
const cannotParseScriptJson = 'Fundme.js: cannot parse JSON from <script fundme>. Make sure it contains a valid JSON.';
const jsonTemplateIsNotArray = 'Fundme.js: found <script fundme> but it\'s not an array.';
const jsonTemplateIsNotArray = "Fundme.js: found <script fundme> but it's not an array.";

const DEFAULT_WEIGHT = 5;
// TODO check pointer.address with RegEx
Expand All @@ -75,9 +74,9 @@ function getPointerAddress(pointer) {
return address;
}
function createPool(pointers) {
return pointers.map(pointer => {
return pointers.map((pointer) => {
let wmPointer;
if (typeof pointer === "string")
if (typeof pointer === 'string')
pointer = convertToPointer(pointer);
if (!('address' in pointer))
throw new Error(addressNotFound);
Expand Down Expand Up @@ -105,7 +104,7 @@ function getChoice(sum) {
function convertToPointer(str) {
const pointer = {
address: str,
weight: DEFAULT_WEIGHT
weight: DEFAULT_WEIGHT,
};
return pointer;
}
Expand Down Expand Up @@ -133,7 +132,7 @@ function scrapeJson() {
const scriptTags = document.body.querySelectorAll(FUNDME_JSON_SELECTOR);
let pointers = [];
if (scriptTags.length > 0) {
scriptTags.forEach(json => {
scriptTags.forEach((json) => {
pointers = parseScriptJson(json);
});
}
Expand All @@ -159,7 +158,7 @@ function scrapeTemplate() {
const templates = document.body.querySelectorAll(FUNDME_TEMPLATE_SELECTOR);
let pointers = [];
if (templates.length > 0) {
templates.forEach(template => {
templates.forEach((template) => {
const pointer = parseTemplate(template);
pointers = [...pointers, pointer];
});
Expand All @@ -168,15 +167,13 @@ function scrapeTemplate() {
}
function parseTemplate(template) {
let address = template.dataset.fund;
let weight = template.dataset.fundWeight !== undefined
? parseInt(template.dataset.fundWeight, 0)
: DEFAULT_WEIGHT;
let weight = template.dataset.fundWeight !== undefined ? parseInt(template.dataset.fundWeight, 0) : DEFAULT_WEIGHT;
if (!address) {
throw new Error(failParsingTemplate);
}
const pointer = checkWeight({
address,
weight
weight,
});
return pointer;
}
Expand All @@ -193,7 +190,7 @@ var FundType;
})(FundType || (FundType = {}));
function fund(pointer, options) {
// const setDefault = options && options.default
if (typeof pointer === "string") {
if (typeof pointer === 'string') {
if (pointer === 'default') {
if (defaultAddress !== undefined) {
if (typeof defaultAddress === 'string') {
Expand Down
29 changes: 13 additions & 16 deletions dist/fundme-iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ var fund = (function (exports) {
return wmAddress;
}
function getPoolWeightSum(pointers) {
const weights = pointers.map(pointer => pointer.weight);
return Object.values(weights)
.reduce((sum, weight) => sum + weight, 0);
const weights = pointers.map((pointer) => pointer.weight);
return Object.values(weights).reduce((sum, weight) => sum + weight, 0);
}
function getWinningPointer(pointers, choice) {
for (const pointer in pointers) {
Expand All @@ -44,8 +43,8 @@ var fund = (function (exports) {

const defaultAddressNotFound = 'Fundme.js: default address not found. Use setDefaultAddress(str: string) to set it first.';
const invalidAddress = 'Fundme.js: Invalid Web Monetization pointer address is given.';
const addressNotFound = "Fundme.js: address not found.";
const addressIsNotAString = "Fundme.js: address must be a string.";
const addressNotFound = 'Fundme.js: address not found.';
const addressIsNotAString = 'Fundme.js: address must be a string.';
function weightIsNotANumber(str) {
return `Fundme.js: ${str} has weight that is not a number. It has been set to ${DEFAULT_WEIGHT} (default).`;
}
Expand All @@ -54,7 +53,7 @@ var fund = (function (exports) {
const failParsingTemplate = 'Fundme.js: fails to parse address from <template data-fund></template>.';
// script json template
const cannotParseScriptJson = 'Fundme.js: cannot parse JSON from <script fundme>. Make sure it contains a valid JSON.';
const jsonTemplateIsNotArray = 'Fundme.js: found <script fundme> but it\'s not an array.';
const jsonTemplateIsNotArray = "Fundme.js: found <script fundme> but it's not an array.";

const DEFAULT_WEIGHT = 5;
// TODO check pointer.address with RegEx
Expand All @@ -74,9 +73,9 @@ var fund = (function (exports) {
return address;
}
function createPool(pointers) {
return pointers.map(pointer => {
return pointers.map((pointer) => {
let wmPointer;
if (typeof pointer === "string")
if (typeof pointer === 'string')
pointer = convertToPointer(pointer);
if (!('address' in pointer))
throw new Error(addressNotFound);
Expand Down Expand Up @@ -104,7 +103,7 @@ var fund = (function (exports) {
function convertToPointer(str) {
const pointer = {
address: str,
weight: DEFAULT_WEIGHT
weight: DEFAULT_WEIGHT,
};
return pointer;
}
Expand Down Expand Up @@ -132,7 +131,7 @@ var fund = (function (exports) {
const scriptTags = document.body.querySelectorAll(FUNDME_JSON_SELECTOR);
let pointers = [];
if (scriptTags.length > 0) {
scriptTags.forEach(json => {
scriptTags.forEach((json) => {
pointers = parseScriptJson(json);
});
}
Expand All @@ -158,7 +157,7 @@ var fund = (function (exports) {
const templates = document.body.querySelectorAll(FUNDME_TEMPLATE_SELECTOR);
let pointers = [];
if (templates.length > 0) {
templates.forEach(template => {
templates.forEach((template) => {
const pointer = parseTemplate(template);
pointers = [...pointers, pointer];
});
Expand All @@ -167,15 +166,13 @@ var fund = (function (exports) {
}
function parseTemplate(template) {
let address = template.dataset.fund;
let weight = template.dataset.fundWeight !== undefined
? parseInt(template.dataset.fundWeight, 0)
: DEFAULT_WEIGHT;
let weight = template.dataset.fundWeight !== undefined ? parseInt(template.dataset.fundWeight, 0) : DEFAULT_WEIGHT;
if (!address) {
throw new Error(failParsingTemplate);
}
const pointer = checkWeight({
address,
weight
weight,
});
return pointer;
}
Expand All @@ -192,7 +189,7 @@ var fund = (function (exports) {
})(FundType || (FundType = {}));
function fund(pointer, options) {
// const setDefault = options && options.default
if (typeof pointer === "string") {
if (typeof pointer === 'string') {
if (pointer === 'default') {
if (defaultAddress !== undefined) {
if (typeof defaultAddress === 'string') {
Expand Down
Loading

0 comments on commit 5e9c09b

Please sign in to comment.