How to use the __rest function from tslib
Find comprehensive JavaScript tslib.__rest code examples handpicked from public code repositorys.
tslib.__rest is a method in the tslib library that creates a new object composed of the properties of an original object, excluding a specified list of properties.
586 587 588 589 590 591 592 593 594 595
case 0: restClient = restClientFactory.build(); headers = {}; fillFormData = function () { var _a, _b; var file = request.file, settings = tslib.__rest(request, ["file"]); formData.append('inputFile', file, { contentType: request.contentType, filename: (_b = (_a = file.name) !== null && _a !== void 0 ? _a : file /* ReadStream */.filename) !== null && _b !== void 0 ? _b : 'file' });
+ 3 other calls in file
59 60 61 62 63 64 65 66 67 68
removeChild: modelRemoveChild, fields: fields.map(createField.bind(this)), }); } function createField(field) { var _a = (0, utility_1.cloneDeepPlain)(field), id = _a.id, type = _a.type, visibility = _a.visibility, other = tslib_1.__rest(_a, ["id", "type", "visibility"]); var element = field.element || (typeof type !== 'string' ? type : this.injector.get(builder_engine_service_1.BuilderEngine).getUiComponent(type)); var _field = { id: id, type: type, element: element, visibility: visibility, field: other }; Object.keys(_field).forEach(function (key) { return _field[key] === undefined && delete _field[key]; }); return _field;
+ 2 other calls in file
How does tslib.__rest work?
tslib.__rest is a method in the tslib library that creates a new object composed of the properties of an original object, excluding a specified list of properties. When you call tslib.__rest(obj, keys), it returns a new object that includes all properties of obj except for those listed in keys. This can be useful when you want to create a new object that is similar to an existing object but with some properties removed. Here's an example of how tslib.__rest works: javascript Copy code {{{{{{{ const _ = require('tslib'); const person = { name: 'John', age: 30, gender: 'male' }; const { gender, ...rest } = _.__rest(person, ['gender']); console.log(rest); // Output: { name: 'John', age: 30 } In this example, we first import the tslib library. We then define a person object that has three properties, name, age, and gender. We then create a new object that includes all properties of person except for the 'gender' property, by calling { gender, ...rest } = _.__rest(person, ['gender']). This uses the spread operator (...) to create a new object that includes all properties of person except for the 'gender' property. Note that tslib.__rest is similar to the Object.assign() method, but with the added benefit of being able to exclude specific properties from the new object. Overall, tslib.__rest is a useful method in the tslib library that allows you to create a new object that is similar to an existing object but with some properties removed.
GitHub: cantinc/ui
28 29 30 31 32 33 34 35 36 37
inputmode: 'numeric', clearMaskOnLostFocus: false, }; const inputDateApply = new jsx.Context('Apply'); function InputDate(_a) { var { apply = jsx.useContext(inputDateApply), value = new watchState.State(), oninput, min = minDate, max = maxDate } = _a, props = tslib.__rest(_a, ["apply", "value", "oninput", "min", "max"]); oninput = actionProp.actionProp(value, oninput); const styles = useStyles(); const showCalendar = new watchState.State(false); const handleCalendarClick = (e) => {
+ 29 other calls in file
GitHub: cantinc/ui
10 11 12 13 14 15 16 17 18 19 20
var Pages = require('../../layout/Pages/Pages.js'); var Flex = require('../../layout/Flex/Flex.js'); const useStyle = dom.style(Title$1["default"]); function Title(_a = {}) { var { h = 1, title, subTitle } = _a, props = tslib.__rest(_a, ["h", "title", "subTitle"]); const children = jsx.useChildren(); const show = dom.useShow(); const hide = dom.useHidden(); const contextTitle = jsx.useContext(Pages.titleContext);
+ 50 other calls in file
Ai Example
1 2 3 4 5 6 7 8 9 10 11
const _ = require("tslib"); const person = { name: "John", age: 30, gender: "male", }; const { gender, ...rest } = _.__rest(person, ["gender"]); console.log(rest); // Output: { name: 'John', age: 30 }
In this example, we first import the tslib library. We then define a person object that has three properties, name, age, and gender. We then create a new object that includes all properties of person except for the 'gender' property, by calling { gender, ...rest } = _.__rest(person, ['gender']). This uses the spread operator (...) to create a new object that includes all properties of person except for the 'gender' property. When the code is run, the output will be the new object { name: 'John', age: 30 }, which is similar to the original person object but with the 'gender' property removed. Overall, tslib.__rest is a useful method in the tslib library that allows you to create a new object that is similar to an existing object but with some properties removed.
GitHub: cantinc/ui
20 21 22 23 24 25 26 27 28 29 30 31
var classes__default = /*#__PURE__*/_interopDefaultLegacy(classes); const useStyle = dom.style(Selector$1["default"]); function Selector(_a = {}) { var { ref = new dom.Ref(), inputRef = new dom.Ref(), placement, value = new watchState.State(''), values, oninput, searchValue, showValues, display = 'auto', search, exact, arrow = exact, onsearch } = _a, props = tslib.__rest(_a, ["ref", "inputRef", "placement", "value", "values", "oninput", "searchValue", "showValues", "display", "search", "exact", "arrow", "onsearch"]); const { '': children, hint, after } = jsx.useSlots(); const styles = useStyle(); const show = new watchState.State(false); const preselect = new watchState.State('');
GitHub: cantinc/ui
9 10 11 12 13 14 15 16 17 18 19
var Pages = require('../../layout/Pages/Pages.js'); var Flex = require('../../layout/Flex/Flex.js'); const useStyle = dom.style(Title$1["default"]); function Title(_a = {}) { var { h = 1, text } = _a, props = tslib.__rest(_a, ["h", "text"]); const children = jsx.useChildren(); const show = dom.useShow(); const hide = dom.useHidden(); const contextTitle = jsx.useContext(Pages.titleContext);
+ 5 other calls in file
GitHub: cantinc/ui
17 18 19 20 21 22 23 24 25 26 27
var Divider = require('../../typography/Divider/Divider.js'); const useStyles = dom.style(InputNumber$1["default"]); function InputNumber(_a = {}) { var _b; var { value = new watchState.State(0), step = 1, oninput, min, max, inputRef = new dom.Ref(), onkeydown } = _a, props = tslib.__rest(_a, ["value", "step", "oninput", "min", "max", "inputRef", "onkeydown"]); const { hint } = jsx.useSlots(); const styles = useStyles(); oninput = actionProp.actionProp(value, oninput); const increase = () => {
tslib.__assign is the most popular function in tslib (16334 examples)