Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sync and checksum script #1000

Merged
merged 13 commits into from
Feb 24, 2021
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ npm-debug.log
# Ignore yarn lockfile and error, in case someone accidentally runs yarn
yarn.lock
yarn-error.log

# Script generated files
/exercises/**/*.sha
/exercise-package.json
/exercise-package.json.sha
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"solution": ["%{kebab_slug}.js"],
"test": ["%{kebab_slug}.spec.js"],
"example": [".meta/proof.ci.js"],
"exemplar": [".meta/examplar.js"]
"exemplar": [".meta/exemplar.js"]
},
"exercises": {
"concept": [
Expand Down
29 changes: 29 additions & 0 deletions exercises/concept/array-loops/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"rules": {
"linebreak-style": "off",

"import/extensions": "off",
"import/no-default-export": "off",
"import/no-unresolved": "off",
"import/prefer-default-export": "off"
}
}
19 changes: 2 additions & 17 deletions exercises/concept/array-loops/.meta/exemplar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,8 @@ export function cardTypeCheck(stack, card) {
* @returns {number} the number of unique cards there any in the stack
*/
export function determineUniqueCards(stack) {
let counts = {};

stack.forEach((c) => {
if (counts[c.toString()] > 0) {
counts[c.toString()]++;
} else {
counts[c.toString()] = 1;
}
});

let uniques = 0;

Object.keys(counts)
.map((key) => counts[key])
.forEach((v) => v === 0 && uniques++);

return uniques;
return stack.filter((card, index, self) => self.indexOf(card) === index)
.length;
}

/**
Expand Down
1 change: 1 addition & 0 deletions exercises/concept/array-loops/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
audit=false
21 changes: 21 additions & 0 deletions exercises/concept/array-loops/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Exercism

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.
18 changes: 9 additions & 9 deletions exercises/concept/array-loops/array-loops.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ describe('array-loops', () => {
});
});

describe('uniqueCards', () => {
describe('oddEvenCards', () => {
/** @type {Array<Array<Array<number>, boolean, number>>>} */
const oddEvenCardsTestCases = [
[[1, 2, 3], true, 1],
[[1, 2, 3, -1, 32, 1, 2, 3], false, 2],
[[1, 2, 3, -1, 32, 1, 2, 3], false, 4],
];

oddEvenCardsTestCases.forEach(([array, isEven, expected]) => {
test(`oddEvenCards([${array}], isEven)`, () => {
expect(oddEvenCards(array, isEven)).toBe(expected);
test(`determineOddEvenCards([${array}], isEven)`, () => {
expect(determineOddEvenCards(array, isEven)).toBe(expected);
});
});
});

describe('oddEvenCards', () => {
describe('uniqueCards', () => {
/** @type {Array<Array} */
const uniqueCardTestCases = [
[[1, 2, 3], true, 3],
[[1, 2, 3, -1, 32, 1, 2, 3], 2],
[[1, 2, 3], 3],
[[1, 2, 3, -1, 32, 1, 2, 3], 5],
];

uniqueCardTestCases.forEach(([array, expected]) => {
test(`uniqueCards([${array}])`, () => {
expect(uniqueCards(array)).toBe(expected);
test(`determineUniqueCards([${array}])`, () => {
expect(determineUniqueCards(array)).toBe(expected);
});
});
});
Expand Down
15 changes: 15 additions & 0 deletions exercises/concept/array-loops/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
useBuiltIns: 'entry',
corejs: 3,
},
],
],
plugins: ['@babel/plugin-syntax-bigint'],
};
31 changes: 31 additions & 0 deletions exercises/concept/array-loops/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@exercism/javascript-concept-array-loops",
"description": "Exercism concept exercise on array-loops",
"author": "Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/javascript"
},
"devDependencies": {
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.1",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.13.5",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.31",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"core-js": "^3.9.0",
"eslint": "^7.20.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3"
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint ."
},
"license": "MIT",
"dependencies": {}
}
3 changes: 3 additions & 0 deletions exercises/concept/basics/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"env": {
"es6": true,
"node": true,
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/basics/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"files": {
"solution": ["basics.js"],
"test": ["basics.spec.js"],
"exemplar": [".meta/examplar.js"]
"exemplar": [".meta/exemplar.js"]
},
"forked_from": ["ruby/basics"]
}
1 change: 1 addition & 0 deletions exercises/concept/basics/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
audit=false
21 changes: 21 additions & 0 deletions exercises/concept/basics/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Exercism

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.
6 changes: 4 additions & 2 deletions exercises/concept/basics/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module.exports = {
presets: [
[
'@babel/env',
'@babel/preset-env',
{
targets: {
node: 'current',
},
useBuiltIns: false,
useBuiltIns: 'entry',
corejs: 3,
},
],
],
plugins: ['@babel/plugin-syntax-bigint'],
};
37 changes: 16 additions & 21 deletions exercises/concept/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,31 @@
"name": "@exercism/javascript-concept-basics",
"description": "Exercism concept exercise on basics",
"author": "Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>",
"version": "1.0.0",
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/v3.git",
"url": "https://github.com/exercism/javascript",
"directory": "languages/javascript/exercises/concept/basics"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@types/jest": "^25.2.2",
"@types/node": "^14.0.1",
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.1",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.13.5",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.31",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"eslint": "^7.0.0",
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.1"
},
"dependencies": {},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
"babel-jest": "^26.6.3",
"core-js": "^3.9.0",
"eslint": "^7.20.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3"
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
}
"lint": "eslint ."
},
"license": "MIT",
"dependencies": {}
}
3 changes: 3 additions & 0 deletions exercises/concept/booleans/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"BigInt": true
},
"env": {
"es6": true,
"node": true,
Expand Down
1 change: 1 addition & 0 deletions exercises/concept/booleans/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
audit=false
21 changes: 21 additions & 0 deletions exercises/concept/booleans/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Exercism

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.
6 changes: 4 additions & 2 deletions exercises/concept/booleans/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module.exports = {
presets: [
[
'@babel/env',
'@babel/preset-env',
{
targets: {
node: 'current',
},
useBuiltIns: false,
useBuiltIns: 'entry',
corejs: 3,
},
],
],
plugins: ['@babel/plugin-syntax-bigint'],
};
Loading