TJX Companies (NYSE:TJX), which owns TJ Maxx, Marshalls, HomeGoods, HomeSense, and Sierra Trading Post, grew even as many of its brick-and-mortar peers crumbled. It accomplished this by selling products at lower prices than Amazon (NASDAQ:AMZN), quickly rotating its products to bring back shoppers, and funneling clearance products from other retailers to its shelves.

Retail peers J.C. Penney and Kohl's recently posted dismal results that indicated that shoppers were still shunning department stores. Yet TJX left both retailers in the dust with a solid first-quarter report on May 21.

TJX's comparable store sales rose 5% on top of its 3% growth a year earlier. Its total revenue rose 7% annually to $9.3 billion, beating estimates by $70 million. Its net income dipped 2% to $700 million, but buybacks boosted its EPS by a penny to $0.57, which cleared expectations by three cents.

TJX expects its comps to rise 2%-3% for the full year, which would mark its 24th straight year of positive comps growth. It hiked its full-year EPS guidance by a penny, which implies that its earnings will grow 5% to 7%. So why does TJX continue to grow even as other retailers succumb to the "retail apocalypse"?

A resilient business model

TJX sources its merchandise from over 21,000 vendors in more than 100 countries. As e-commerce marketplaces like Amazon (NASDAQ:AMZN) crush smaller brick-and-mortar retailers, TJX's vendor network scoops up their inventories at rock-bottom prices -- which makes it a beneficiary of the retail apocalypse instead of another victim.

This strategy enables TJX to sell its merchandise at a 20%-60% discount and still make a profit. TJX then lures shoppers back to its stores for "treasure hunts" by quickly rotating its products. TJX opened 75 new stores during the first quarter, bringing its total store count to 4,381 locations and bucking the industrywide meltdown in brick-and-mortar stores.

Its core business units -- Marmaxx (Marshalls and TJ Maxx), HomeGoods, and TJX International (Europe and Australia) -- all posted positive comps growth during the first quarter. The only soft spot was TJX Canada, which reported flat growth due to unseasonable weather. However, TJX expects comps to rise across all four segments -- including Canada -- for the full year.

Shareholder-friendly moves

TJX also spends a lot of its excess cash on buybacks and dividends. It bought back $350 million in shares during the first quarter, which was well-timed given the stock's rally of nearly 20% this year.

TJX plans to repurchase up to $2.25 billion in shares for the full year, which represents about 3% of its current market cap. That would slightly reduce its valuation, which is already fairly low at 19 times forward earnings. TJX's closest rival, Ross Stores (NASDAQ:ROST), trades at 20 times forward earnings.

TJX spent $239 million on dividends during the quarter, and it raised that payout 18% in April, marking its 23rd straight year of dividend hikes. It currently pays a forward yield of 1.7%, and its dividends would use just over a third of its estimated EPS for the full year. Ross pays a lower forward yield of 1%.

But mind the margins and tariffs

TJX's core business looks solid, but its lower merchandise margin, higher supply chain costs, higher freight costs, and new store openings caused its gross margin to contract 40 basis points annually to 28.5%.

It expects its second-quarter gross margin to come in between 28.2% and 28.3%, compared to 28.9% a year earlier. The recent tariff hike on Chinese goods could exacerbate those declines throughout the year.

During the conference call CEO Ernie Herrman refused to disclose the percentage of its products sourced from China. Herrman admitted that the trade war caused "little snippets of disruption," but there was "nothing meaningful at this point" and the company remains "on standby" in regards to higher tariffs. A strong dollar also remains a headwind for the company's overseas businesses, since foreign currency headwinds already reduced its EPS by 2% in the first quarter.

Cautiously optimistic about the future

TJX's forecast for positive earnings growth indicates that it will offset those headwinds with buybacks, but investors should keep a close eye on its margins and scrutinize its comments about tariffs over the next few quarters.

I'm cautiously optimistic about TJX -- it remains a "best in breed" play in the tough retail market -- but its contracting margins indicate that it isn't invulnerable to macro headwinds.

This article originally appeared in The Motley Fool.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Leo Sun owns shares of Amazon. The Motley Fool owns shares of and recommends Amazon. The Motley Fool recommends The TJX Companies. The Motley Fool has a disclosure policy.

tj maxx
A view of the sign outside the TJ Maxx store in Westminster, Colorado, Feb. 26, 2014. Reuters/Rick Wilking