Skip to content

Commit

Permalink
Migrate to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Jan 8, 2022
1 parent 15d7440 commit 08bc4cc
Show file tree
Hide file tree
Showing 16 changed files with 1,237 additions and 248 deletions.
10 changes: 7 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended"
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": [
"@typescript-eslint"
],
"env": {
"es6": true,
"node": true,
"jest": true
"worker": true
},
"parserOptions": {
"sourceType": "module"
Expand Down
56 changes: 0 additions & 56 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
'use strict';

/**
* Create Repeated Item Scope
* https://github.com/shoonia/repeater-scope
*
* @typedef {{
* _id: string;
* [key: string]: any;
* }} ItemData;
*
* @typedef {{
* $item: $w.$w;
* itemData: ItemData;
* index: number;
* data: ItemData[];
* }} ScopeData;
*
* @param {() => ItemData[]} getData
* @returns {(event: $w.Event) => ScopeData}
*/
var createScope = function createScope(getData) {
return function (event) {
var ctx = event.context;
Expand Down Expand Up @@ -46,15 +27,7 @@ var createScope = function createScope(getData) {
};
};

/**
* Get parent Repeater by event
* https://github.com/shoonia/repeater-scope
*
* @param {$w.Event} event
* @returns {$w.Repeater}
*/
var getRepeater = function getRepeater(event) {
/** @type {*} */
var node = event.target;

if (event.context.type !== 'COMPONENT_SCOPE') {
Expand All @@ -68,26 +41,6 @@ var getRepeater = function getRepeater(event) {
return node;
};

/**
* Use Repeated Item Scope
* https://github.com/shoonia/repeater-scope
*
* @typedef {{
* _id: string;
* [key: string]: any;
* }} IData;
*
* @typedef {{
* $item: $w.$w;
* itemData: IData;
* index: number;
* data: IData[];
* }} IScopeData;
*
* @param {$w.Event} event
* @returns {IScopeData}
*/

var useScope = function useScope(event) {
var ctx = event.context;

Expand All @@ -113,15 +66,6 @@ var useScope = function useScope(event) {
};
};

/**
* Update Repeated Item by event
* https://github.com/shoonia/repeater-scope
*
* @param {$w.Event} event
* @param {$w.ForItemCallback} callback
* @returns {void}
*/

var updateItem = function updateItem(event, callback) {
getRepeater(event).forItems([event.context.itemId], callback);
};
Expand Down
56 changes: 0 additions & 56 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/**
* Create Repeated Item Scope
* https://github.com/shoonia/repeater-scope
*
* @typedef {{
* _id: string;
* [key: string]: any;
* }} ItemData;
*
* @typedef {{
* $item: $w.$w;
* itemData: ItemData;
* index: number;
* data: ItemData[];
* }} ScopeData;
*
* @param {() => ItemData[]} getData
* @returns {(event: $w.Event) => ScopeData}
*/
var createScope = function createScope(getData) {
return function (event) {
var ctx = event.context;
Expand Down Expand Up @@ -44,15 +25,7 @@ var createScope = function createScope(getData) {
};
};

/**
* Get parent Repeater by event
* https://github.com/shoonia/repeater-scope
*
* @param {$w.Event} event
* @returns {$w.Repeater}
*/
var getRepeater = function getRepeater(event) {
/** @type {*} */
var node = event.target;

if (event.context.type !== 'COMPONENT_SCOPE') {
Expand All @@ -66,26 +39,6 @@ var getRepeater = function getRepeater(event) {
return node;
};

/**
* Use Repeated Item Scope
* https://github.com/shoonia/repeater-scope
*
* @typedef {{
* _id: string;
* [key: string]: any;
* }} IData;
*
* @typedef {{
* $item: $w.$w;
* itemData: IData;
* index: number;
* data: IData[];
* }} IScopeData;
*
* @param {$w.Event} event
* @returns {IScopeData}
*/

var useScope = function useScope(event) {
var ctx = event.context;

Expand All @@ -111,15 +64,6 @@ var useScope = function useScope(event) {
};
};

/**
* Update Repeated Item by event
* https://github.com/shoonia/repeater-scope
*
* @param {$w.Event} event
* @param {$w.ForItemCallback} callback
* @returns {void}
*/

var updateItem = function updateItem(event, callback) {
getRepeater(event).forItems([event.context.itemId], callback);
};
Expand Down
Loading

0 comments on commit 08bc4cc

Please sign in to comment.