Skip to content

Commit

Permalink
add src
Browse files Browse the repository at this point in the history
  • Loading branch information
zavr-1 committed Feb 6, 2020
1 parent 670042a commit 1e1b13d
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 180 deletions.
17 changes: 17 additions & 0 deletions build/factory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { Octopus } = require('./lib');

/**
* Create a new octopus.
* @param {Food} initialFood
*/
function makeOceanOctopus(initialFood) {
const octopus = new Octopus('ocean')
octopus.eat(initialFood)
return octopus
}

/**
* @typedef {import('./lib').Food} Food
*/

module.exports.makeOceanOctopus = makeOceanOctopus
25 changes: 24 additions & 1 deletion build/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*!
* @artdeco/typescript: TypeScript bug.
*
* Copyright (C) 2020 Art Deco Code Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const { c } = require('../stdlib');

/**
Expand All @@ -16,6 +35,9 @@ async function typescript(config = {}) {
return text
}

const $_factory = require('./factory');


/* typal types/index.xml namespace */
/**
* @typedef {_typescript.Config} Config `@record` Options for the program.
Expand All @@ -25,4 +47,5 @@ async function typescript(config = {}) {
*/


module.exports = typescript
module.exports = typescript
module.exports.makeOceanOctopus = $_factory.makeOceanOctopus
26 changes: 26 additions & 0 deletions build/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* An ocean creature.
*/
class Octopus {
/**
* @param {string} location
*/
constructor(location) {
this.location = location
}
/**
* Eat some food.
* @param {string} food What food to eat.
*/
eat(food) {
console.log(food)
}
}

/**
* @typedef {Object} Food
* @prop {number} quantity
* @prop {number} calories
*/

module.exports.Octopus = Octopus
15 changes: 15 additions & 0 deletions src/factory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Octopus } from './lib'

/**
* Create a new octopus.
* @param {Food} initialFood
*/
export function makeOceanOctopus(initialFood) {
const octopus = new Octopus('ocean')
octopus.eat(initialFood)
return octopus
}

/**
* @typedef {import('./lib').Food} Food
*/
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default async function typescript(config = {}) {
return text
}

export { makeOceanOctopus } from './factory'


/* typal types/index.xml namespace */
/**
* @typedef {_typescript.Config} Config `@record` Options for the program.
Expand Down
24 changes: 24 additions & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* An ocean creature.
*/
export class Octopus {
/**
* @param {string} location
*/
constructor(location) {
this.location = location
}
/**
* Eat some food.
* @param {string} food What food to eat.
*/
eat(food) {
console.log(food)
}
}

/**
* @typedef {Object} Food
* @prop {number} quantity
* @prop {number} calories
*/
5 changes: 0 additions & 5 deletions src/stdlib.js

This file was deleted.

139 changes: 0 additions & 139 deletions stdlib/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions stdlib/index.js.map

This file was deleted.

31 changes: 5 additions & 26 deletions test/spec/default.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
import { equal, ok } from '@zoroaster/assert'
import Context from '../context'
import typescript from '../../src'
import { makeOceanOctopus } from '../../src'

/** @type {TestSuite} */
const T = {
context: Context,
'is a function'() {
equal(typeof typescript, 'function')
},
async 'calls package without error'() {
await typescript()
},
async 'gets a link to the fixture'({ fixture }) {
const text = fixture`text.txt`
const res = await typescript({
text,
})
ok(res, text)
},
}

/**
* @typedef {import('../context').TestSuite} TestSuite
*/

export default T
makeOceanOctopus({
calories: 100,
quantity: 10,
})

0 comments on commit 1e1b13d

Please sign in to comment.